For purposes of this example, the mail domain is domain.xyz and there will be two servers running qmail. The primary MX server's host name is a.mx.domain.xyz and it's IP address is 1.2.3.4. The secondary MX's server's host name is b.mx.domain.xyz and it's IP address is 2.3.4.1.
Install qmail on the secondary MX according the instructions in the INSTALL file in the qmail tarball. Stop after step 3.
Next run the following command to create the "me" file with the unique hostname of the server.
# echo "b.mx.domain.xyz" > /var/qmail/control/me
Add the domain(s) to the "rcpthosts" control file.
# echo "domain.xyz" >> /var/qmail/control/rcpthosts
Create an empty locals file.
# touch /var/qmail/control/locals
# chmod 644 /var/qmail/control/locals
At this point the new machine should have the following files under /var/qmail:
control/me b.mx.domain.xyz control/rcpthosts domain.xyz control/locals (exists but is zero bytes)
The file /var/qmail/control/virtualdomains should not exist on the machine.
Create an MX record in your DNS data which points to the secondary MX server with a higher priority than the existing MX record. The existing MX record should point to your primary server. Note, a higher priority MX record is tried after a lower priority MX record. The two examples below show configuration for tinydns (preferred) and BIND (nervous tic).
Tinydns configuration
@domain.xyz:1.2.3.4:a:1 (already existed)
@domain.xyz:2.3.4.1:b:2 (add to the file)
BIND configuration
a.mx.domain.xyz. IN A 1.2.3.4 (already existed) domain.xyz. IN MX 1 a.mx.domain.xyz. (already existed) b.mx.domain.xyz. IN A 2.3.4.1 (add to the file) domain.xyz. IN MX 2 b.mx.domain.xyz. (add to the file)
A special thanks goes to John Simpson. His response to the thread titled "nuB question: relay" on the qmailrocks mailing list made this the easiest web page to write. I simply took his words and added the HTML.