This document describes how to setup two qmail servers, one as the primary mx server and one as a backup server.
Configuring two mailservers for one domain has the advantage, that one has a redundant mail system. If the delivery of an email fails because of the temporary unavailability of the primary mail server, the backup server stores them all in a queue and sends them to the primary server as soon as this one is up again. For that purpose, we have to setup the DNS for that domain with two MX entries with two different priorities in the zonefile. In the following, we assume you have a standard qmail installation with vpopmail installed.
First we have to make sure, your domain has two MX entries in the zonefile. There shoud be two lines looking somehow like this:
@ IN MX 10 mail1 @ IN MX 20 mail2
And give those two third level domains an address:
mail1 IN A 123.456.78.0 mail2 IN A 123.456.78.1
It says, that mail1.mydomain.com has the address 123.456.78.0 and works as the primary mx server with higher priority (10). mail2.mydomain.com will be our backup server.
Now restart your named. On RedHat you can do this by typing
# service named restart
After setting up the domain parameters we can test the named configuration by this
# host mail1.mydomain.com mail1.mydomain.com has address 123.456.78.0
and the same for mail2. Now we are ready to setup qmail!
Create a new mail domain on mail1. On a standard vpopmail installation do the following:
# cd /home/vpopmail/bin # ./vadddomain mydomain.com
You can add a user to this domain doing
# ./vadduser myname@mydomain.com
mail1 is now ready for relaying email for the domain ``mydomain.com''.
To ensure that mail2 takes the emails for the domain ``mydomain.com'' too, we just have to add the domain to the rcpthosts file:
# cd /var/qmail/control # echo "mydomain.com" >> rcpthosts
Now restart qmail:
# /etc/rc.d/init.d/qmail restart or
# service qmail restart
mail2 will now relay all emails for our domain ``mydomain.com'' and store them in a queue for mail1.
Rafael Perez, securemailer at _superrafi_ dot com