I want to send email from a C++ program.
I want to do it using sendmail. Well, actually I don't care how, I just found that none of the smtp libaries work...
The way to do this, I found via google, is this:
echo "This will go into the body of the mail." | mail -s "Subject line" [email protected]
The problem is, the mail never arrives at destination. Now what I find peculiar: Shouldn't there be a need for a smtp-server URL? Such as smtp.my-provider.com:25 ?
Sendmail will try to look up the MX record of the domain you're sending to, so you wouldn't have to specify the SMTP server's address or hostname by default. If you do need to force a particular address, that can be handled via DNS or an entry in the Sendmail mailertable file.
You should first try to determine what happened to your original message. Try sending from your application and running:
You can also view the mail queue directly by using the "mailq" command. If that command returns output, you can try to force the queue to be processed with "sendmail -v -q". That will reveal the nature of the error.
Also check the root user's email for bounce-back messages.
There's no need for an SMTP-server DNS name because the
mail
command expects to communicate with a local Mail Transport Agent (MTA) on the same machine. For Linux that MTA is often Sendmail. The sendmail configuration might include the DNS name of your ISP's mail-server (MTA) as a smarthost if you need to route outgoing mail through your ISP's mail-server.I would check the mail logs to see what happened to your outboind mail. It might be queued for delivery and you might get a non-delivery report in due course.