Sendmail on domain host

If you followed my guide for Ubuntu Lucid VPS Base Build then /etc/hosts will have the following DNS entries and aliases: localhost.localdomain localhost servername.domainname alias.domainname

This is ok as the servername and alias are subdomains. Any email sent to user@domainname will be delivered as expected by SMTP using the MX entry for the domain.

However, it is possible to have an alias in the hosts file for the domain itself, e.g.: localhost.localdomain localhost servername.domainname alias.domainname domainname

A consequence of this is that email to user@domainname from that server will be delivered locally instead.

Of course, this may be the desired behaviour, in which case it would warrant a more complicated setup. For example; in a single server environment, instead of using aliases, a mail delivery agent (MDA) could deliver the mail to a mailbox that users can interact with accordingly. Multi-server environments may have a mail server, in which case the other servers may have sendmail configured to use it as a smart host, e.g. the following may be added to /etc/mail/

define(`SMART_HOST', `mail.domainname')

Getting back to a simple setup where email should be relayed, e.g. where email is provided by an external party such as gmail, the following lines can be added to the end of /etc/mail/ to effectively disable local delivery:

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

Note the dot after the domainname. This allows the local routing to be circumvented. You can also make the email addresses a little nicer by adding the following lines before the MAILER_DEFINITIONS section:


When making modifications to /etc/mail/, be sure to run sendmailconfig afterwards to update the compiled configuration and restart sendmail to use the new configuration.


blog comments powered by Disqus
Fork me on GitHub