Sendmail’s unwanted insistence on local delivery


August 13, 2013

Here’s another quick post to record one of those 2-line solutions to a problem that took considerable searching to find. This one affects outgoing mail passing through sendmail when the recipient’s email address matches the machine’s hostname, but the machine is not the mail server for the domain. For example, my dedicated server is configured as, and sends logs and such to my email. Sendmail on this machine works fine for emails to other domains, but the trouble is, as every other email server in the entire world besides mine knows, mail destined for addresses should be sent to the smtp sever at Instead of looking up the mx record for to see if it actually is the mail server, it just assumes it is, looks for the recipient’s name in its local user database, and either delivers the message locally or doesn’t find a local mailbox and gives up.

The fix: add the following two lines to the end of /etc/mail/

define(`MAIL_HUB', `')dnl
define(`LOCAL_RELAY', `')dnl

Then rebuild the sendmail configuration, which on Ubuntu can be accomplished by running sendmailconfig.

Since sendmail is going to be with us for the foreseeable future, I’m sure I’ll need to refer back to this tip someday. Thanks to for the solution.