Jun 10 2008

HOWTO: Configure Sendmail as a backup mail server

Setting up a backup mail server is very easy. It’s also very important since you do not want to be without mail if your primary mail server goes down. To setup a backup mail server, first setup the MX record for the domain in question so that the backup mail server handles mail second (or third…) for the domain. Once your MX record is in place, you need to configure the backup server.

The first step is to make sure that the host name referenced in the MX record is listed as a local host name, either using the Cw option or the /etc/mail/local-host-names file. As an example, if I setup the MX record so that my backup mail server is mail2.domain.com, I should have Cwmail2.domain.com in my sendmail.mc file or have mail2.domain.com listed in my /etc/mail/local-host-names file. If it is not listed, Sendmail may get confused and bounce mail with the message:

553 MX problem? mail loops back to me

You’ll only see this message when your main mail server goes down. This happens presumably because Sendmail tries to relay mail to the backup mail server as listed in the MX record if it cannot reach the primary mail server. Since the MX record points to a host that is not recognized by Sendmail as a local host, it will keep trying to send the mail to the backup server. As it tries, it finds that the address points to itself, which it believes is not right, creating a loop. By letting Sendmail know that this is indeed another alias for this machine, it will handle the mail properly, queuing it for later delivery to the primary mail server.

It is important that you do not include the top level domain for which you are the backup server in the local-host-names file. Otherwise, your mail server will treat that domain as being local and will try to accept mail (as opposed to relay mail) for that domain. For example, if you include domain.com in your local-host-names file (in addition to mail2.domain.com), your mail server will think that IT is the primary mail server for domain.com and try to deliver messages locally.

The next step is to include domains for which you will be a backup server in the /etc/mail/access file and allow relaying for those domains. Continuing with the example above, your access file might have the following lines:

domain.com RELAY
domain2.com RELAY

On my viaVerio server I run these commands after modifying the config files:

cd /etc/mail
make && make install && restart_sendmail
Mar 21 2005

HOWTO: Configure QMail as a backup mail server

Read more »