Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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"

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 ?

share|improve this question
up vote 1 down vote accepted

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:

tail -f /var/log/maillog

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.

share|improve this answer
There was no such logfile. But mailq reveiled that a message was frozen. With exim -Mb and exim -Mh I was able to look at the header and message. exim -bp gave me the message ID and exim -Mrm <id> removed the message in question. – Quandary Nov 14 '10 at 19:38

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.