Configure Postfix as a backup MX
In order to configure postfix as a backup mx, you need to make some changes to the configuration file :
Add the following line to the main.cf file:
vi /etc/postfix/main.cf
Add permit_mx_backup to the smtpd_restrictions :
smtpd_recipient_restrictions = current_restrictions, permit_mx_backup
permit_mx_backup_networks = x.x.x.x
Note : permit_mx_backup is not really necessary when you have the domains in relay_domains.
Now in order for the domains to act as a backup domain , these domains need to be added to the relay_domain option :
relay_domains = $mydestination domain1.com domain2.com domain3.com
Now the postfix will accept mails destined for these domains, now we need to tell it where to send these mails to , so we add transport_maps. Add the following to your main.cf :
transport_maps = hash:/etc/postfix/transport
When you make any changes to this file above, you will have to regenerate the hash by running the following command :
postmap /etc/postfix/transport
Sample transport file :
domain1.com smtp:mail.domain1.com domain2.com smtp:mail.domain2.com:2792
You can optionally define, how many days will the mails remain in queue if the primary mail server is down , by the following parameter :
maximal_queue_lifetime = 30d
Only a minor note: permit_mx_backup
is not needed when domains are listed in relay_domains
. permit_mx_backup
can be vulnerable to mis-use when access is not restricted with .