This article will guide how to set up a Postfix mailserver as a backup MX (mail exchanger) for a domain condition by if the primary mail server is down or unreachable, it will accept and hold the messages in a queue until primary server to become online.
In this article we are going to set up a backup MX for the domain mydomain.com. And it’s primary MX for mydomain.com is called mail.mydomain.com (IP address 192.168.1.4), so I describe the backup MX backupmx.mydomain.com (IP address 192.168.1.5).
We have created MX records for mydomain.com as below:
mydomain.com . 86400 IN MX 10 backupmx. mydomain.com .
Here we assume that the Postfix on mail.mydomain.com is already installed and working fine.
Install and configure postfix on backupmx.mydomain.com.
After install postfix successfully on backup mx open /etc/postfix/main.cf and make following changes.
relay_recipient_maps =
relay_domains = hash:/etc/postfix/relaydomains
transport_maps = hash:/etc/postfix/transportmaps
smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination
OR
relay_domains = mydomamin.com
Note: If you have more than one domain you can add them by comma separated domain.
Then create file with name /etc/postfix/relaydomains and append your domain name.
create /etc/postfix/transportmaps file and append following lines.
Everytime a change have been made to either the transportmaps, or relaydomains files it is needed to run postmap to create/update the postfix database table.
#postmap /etc/postfix/relaydomains
#service postfix restart
You can also use the following script to update postfix database.
Postfixupdate.sh
echo “running postmap”
postmap /etc/postfix/transportmaps
postmap /etc/postfix/relaydomains
echo “restarting postfix, to accept changes”
/etc/init.d/postfix restart
echo “done”
If everything working fine, mails should start comming in, in the mailqueue on the backup MX server
tail -f /var/log/mail.log
That’s.
Note: The same procedure is also applicable for multiple domains.
You need to take part in a contest for one of the most useful sites on the net.
I most certainly will recommend this web site!