I need to send emails DIRECLTY to the recipient's mail-server, bypassing any MTA's on my end. I know there are some great reasons to use MTAs like sendmail, etc, so I don't need advice in that direction. I would like to write code that directly connects to the recipient's mailservers.
So, am I missing anything here?
- Suppose the destination email is [email protected]
- Look up the MX records for domain.com and pick a random MX entry. We'll call this "server"
- If there is no MX record for domain.com, use "domain.com" as the "server"
- Connect to "server" at port 25.
- Transmit this:
HELO myserver.com
MAIL FROM: <[email protected]>
RCPT TO: <[email protected]>
DATA
Subject: This is a test
Hello, this is a test message.
QUIT
This has worked in a lot of cases. What I am wondering is -- what am I missing? Are there any cases when this won't work, and I'll have to do something more special?
Can I test it as we go -- if the remote server I connect to says "MESSAGE ACCEPTED FOR DELIVERY" can I assume that it's going to go through?