Richard
If you have the luxury of two computers connected to the internet using different IP-addresses you could use one of them as your backup mailserver. This backup server will receive email for the domains on your primary server when it is off-line or unreachable.
First install and configure your backup server just like you would a regular server. Install the following components as a minimum (it’s best just to install everything when possible):
- MySQL, Apache and PHP
- The basic mailserver (postfix & courier)
- Postfixadmin
When you’ve done that make the changes listed here on your intended backup server.
First you need to create a file in the directory ‘/etc/postfix‘ called ‘mysql_relay_domains_maps.cf‘, which should contain:
password = postfixpassword
hosts = 127.0.0.1
dbname = postfix
query = SELECT domain FROM domain WHERE domain=’%s’ AND backupmx = ’1′ AND active = ’1′
To make sure that mail does not get delivered to the backup server you need to change the file ‘mysql_virtual_domains_maps.cf‘ in the directory ‘/etc/postfix‘. Change the line:
into:
Then add the line:
to the file ‘main.cf‘ in the ‘/etc/postfix‘ directory.
Then to activate the configuration restart postfix by using the command:
Go to your Postfix admin website and configure the domains you want to use. Basically you will configure this identically to your primary server. The only difference here is that you check the backup MX checkbox.

Finally you’ll need to add a record to your DNS entries. Make sure the priority for the backup MX is lower than the primary server. Here is how I entered the information for DIYMacServer:
mail.diymacserver.com 10 64.79.143.195
mail2.diymacserver.com 20 82.161.58.127



Comments
11:08 pm
erm. I set up what you sujested. everything seems to work. however, if you turn off the mx 1 for testing. the mail gets deffered, and not qued. so is this really a backup mail server?
9:01 pm
The mail should be stored on your backup-mx and as soon as the primary is available it should be forwarded to it. You can only read mail from the primary server with your mail client.
12:09 am
It is not necessary to add an entry in
/etc/postfix/transport?
I thought it was (cf. http://samat.org/node/configuring_postfix_to_act_as_a_backup_mx_server)
But I love postfixadmin and it should be improved to allow this kind of configuration.
Thanks!
8:50 am
It is not necessary as we use mysql for all transportmaps and for the relaying we use the option “relay_domains” with the SQL statement to get the correct information from mysql.
12:46 am
What about $CONF['transport_default'] = ‘relay’; in config.inc.php postfixadmin config file?
4:55 am
Not required to define transports as we are using virtual domains.
5:56 am
Just got a new mini with SL server, was thinking about repurposing my current ppc leopard diymacserver for the backup relay mail server. I was thinking about wiping it and starting from scratch with Dovecot this time. Is it possible, and if so, do you foresee any problems I might run into.
6:30 am
@Richard, no real issues. Just install everything as normal and then apply these instructions. If something might go wrong there is still no Mail lost.
11:44 am
THANKS!
Been trying to fix this problem for a while now – just assumed that postfixadmin would set the whole thing up as thats what it looks like its doing when you configure as backup MX.
Do you know what triggers the mail to be sent from backup mx to primary? Does the backup continually check? Or the primary alert the backup?
Thanks again!
10:02 pm
@Kavz, Postfix keeps trying this at certain time intervals. So you could consider it continuous.
9:34 am
Had this running over the weekend and even the domains that are not set to backupmx were being queued. When I removed the relay_domains line from main.cf all the mail started being delivered again (even the ones over the weekend that had been queued)
Obviously now the backupmx isn’t in place… it is possible to run both types on one server?
6:14 pm
@Kavz, This should be possible I had this running as well. Make sure you have all the changes well implemented. It sounds like a problem in the query where the backup domains aren’t properly selected.
5:35 pm
nice howto. works great. thx.