Sendmail is a notoriously finicky piece of software, with an arcane settings syntax and methodology. Here’s a problem I ran into, and what I did to fix it.


When I was setting up our sipXecs phone system on Centos 6, one problem that I ran into was the fact that I could not get voicemail to automatically send out. The voicemail feature was indeed working, judging from the logs and .wav files’ presence in the web GUI. However, no amount of cajoling could get sendmail to cooperate, and just email users their voicemails.

What Happened

I noticed a lot of messages in /var/mail/maillog regarding delays and timeouts. This generally means that something is not working, but, depending upon the recipient, mail was sending out sometimes, albeit after a long delay. The most important recipients would be my company colleagues, and that is what was not working, so that had priority.

I took a bunch of time searching for solutions, based on the exact log messages, which ended up being pretty useless. Here’s a typical log entry:

Apr 12 11:21:36 sipserver1 sendmail[7889]: u3B84xT9931967: to=, ctladdr= (0/0), delay=18:16:37, xdelay=00:00:00, mailer=esmtp, pri=43710276,, dsn=4.0.0, stat=Deferred: Connection timed out with

Not really specific information, except to say there’s a timeout and the message has been Deferred (you can view the queued ones with mailq).

Here’s what I did to Resolve it

A bunch of trial and error and fits and starts later, here’s basically what I did in a nice, neat order:

  1. Ensure /etc/hosts has your hostname right.
  2. Add the sipXecs server’s public host IP to DNS “SPF” entry for our domain. If you don’t have SPF enabled for your domain, you should get it set up. It’s one standard besides DKIM , and really helps with email security. Here’s a wizard for creating an entry that you can then cut and paste into your DNS TXT record.
  3. Enabled smtp relay in Google Apps admin console, setting it to allow the specific IP of our sipXecs server.
  4. Added Google’s specified smtp server hostname, as a “smart host” in sendmail on the sipXecs server, then recompiled the configs as you need to do with sendmail.
  5. Flushed the sendmail queue.

And boom, all of a sudden, email is flowing and we’ve got (a lot) of mail.

Let’s loop back a sec:

What should /etc/hosts look like

Basically, like this, assuming a hostname of sipserver1 and a domain name of

cat /etc/hosts sipserver1   localhost localhost.localdomain localhost4 localhost4.localdomain4 sipserver1   sipserver1
    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

SipXecs does fill in the hosts file for you, but this one you can edit, without sipXecs overwriting it automatically. Just make sure the information matches what’s represented in your sipXecs settings.

Edit and recompile Sendmail config

Logo -
Logo -

Sendmail’s a beast, but basically here’s what I did this time.

First, change into the /etc/mail directory (I’m using Centos 6.2 for this), and edit the

cd /etc/mail

Search for the line with SMART_HOST near the top, uncomment it (remove the dnl #), and add the Gmail smart host hostname.

define(`SMART_HOST', `')dnl

Now you need to recompile the file, do a make in the mail folder, and then restart the sendmail service.

cd /etc/mail
m4 >
service sendmail restart

Finally, while checking your maillog and sendmail queue, enter the queue flush command:

tail -n 100 /var/log/maillog
sendmail -OTimeout.hoststatus=0m -q -v

For me, mail started to flow after I flushed the queue, after the configuration step.

I hope this post saves someone some time. Stay safe out there, kids.


The banner photo is a monochrome version of some Pony Express postmarks, in keeping with the “postal” theme. You can view the original here.