MX backup server with postfix on debian



Not to lose mails when main mail server is down, best solution is – mx backup server.

This is configuration to have backup mx server set up and running.

myhostname =
mynetworks =
maximal_queue_lifetime = 120d
smtpd_banner = $myhostname ESMTP

relay_domains = hash:/etc/postfix/relaydomains
transport_maps = hash:/etc/postfix/transportmaps

smtpd_recipient_restrictions =

create /etc/postfix/relaydomains with contents: OK
otherdomain.tld OK

then to create map for postfix – run:

postmap /etc/postfix/relaydomains

create /etc/postfix/transportmaps with contents:
otherdomain.tld smtp:primary_mx_server:port

and run:

postmap /etc/postfix/transportmaps

Backup MX should be added in DNS zone in order to receive mails.
In my case I have such records:

% dig mx +short

First digit means priority. The bigger value, the smaller priority.
So my MX backup server is mx2. It receives mail only if higher priority server is down.

That’s it.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.