How to Set Up Secondary MX on Qmail and Sendmail
Whenever we host DNS for a customer on a foreign/external network, it is often required or negotiated that we provide backup mail services for the customer in case their own mail server were to go down. Here’s how to set up sendmail and qmail for this.
SENDMAIL
Pretty straightforward. Edit /etc/mail/relay-domains and put the domain name in that you wish to handle mail for as a secondary. If you run into “mail loops back to me” errors in your log, you can always use this information from http://www.faqts.com/knowledge_base/view.phtml/aid/26702/fid/232
server.somedomain.com smtp:[mail1.somedomain.com]
.somedomain.com smtp:[mail1.somedomain.com]
The latter example would cover *.somedomain.com (a great space-saver), but not somedomain.com itself, so far as I know.
The important, poorly documented detail is in the brackets surrounding the hostname on the right. Normally, sendmail would check what the MX records say to do, which in this case would be “try mail1 first, and if that fails, try mail2.” If mail1 was down, it would try mail2 (which is itself, unfortunately), causing the wonderful “mail loops back to me (MX problem?)” error. The brackets, however, tell it to ignore MX records completely and do exactly as you say.
QMAIL
- Set up DNS properly.
- Add the domain to /var/qmail/control/rcpthosts file.
- Send qmail the HUP signal with “qmailctl reload”
See this link for more info on qmail secondary configuration.