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.
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: u3B84xT9931967: to=
, ctladdr= (0/0), delay=18:16:37, xdelay=00:00:00, mailer=esmtp, pri=43710276, relay=ourtest.com., dsn=4.0.0, stat=Deferred: Connection timed out with ourtest.com.
Not really specific information, except to say there’s a timeout and the message has been Deferred (you can view the queued ones with
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:
/etc/hostshas your hostname right.
- 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.
- Enabled smtp relay in Google Apps admin console, setting it to allow the specific IP of our sipXecs server.
- Added Google’s specified smtp server hostname
smtp-relay.gmail.com, as a “smart host” in sendmail on the sipXecs server, then recompiled the configs as you need to do with sendmail.
- 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 192.168.10.10 sipserver1.ourtest.com sipserver1 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 sipserver1 127.0.1.1 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
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 vim sendmail.mc
Search for the line with
SMART_HOST near the top, uncomment it (remove the dnl #), and add the Gmail smart host hostname.
Now you need to recompile the sendmail.mc file, do a
make in the mail folder, and then restart the
cd /etc/mail m4 sendmail.mc > sendmail.cf make service sendmail restart
Finally, while checking your
maillog and sendmail queue, enter the queue flush command:
tail -n 100 /var/log/maillog mailq 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.