For website owners, emails play a crucial role in their business.

So, they prefer to use a correctly configured Backup mail exchanger, as a part of their disaster recovery plan.

However, this requires some extra work to configure the server as a Backup Mail Exchanger.

In our role as Outsourced Technical Support we help our web hosts and server owners setup their server as a Backup Mail Exchanger.

Today, let’s discuss the steps to configure the server as a Backup Mail Exchanger.


What is Backup Mail Exchanger?

We’ve seen broadly 2 cases where website owners complain about their email delivery.

  • Bounced emails – If the primary mail server is down or inaccessible, and the retry time has expired, all emails will be bounced.
  • Delayed emails – High load on the primary mail server can cause delays in email delivery.


Your primary email server may goes down due to various reasons like server crashes, high load, security updates etc.

In this case, you can setup a backup mail exchanger to route all the emails to this server.

This queues all emails and relay those queued emails to the primary server once it is available.

At Bobcares, for the servers that we manage, we often configure backup mail exchanger as a part of the disaster recovery plan, to recover emails in case of crash


Steps to setup Backup Mail Exchanger

Now, let’s see how our Dedicated Support Engineers configure a server as backup mail exchanger.

1) Configure the server as Backup mail exchanger

We perform a series of steps to configure a backup mail server.


a) Set correct hostname

Firstly,  we ensure that the hostname of the mail server is correct.

This hostname is used by the mail server when it connects to another server on the internet.

For example, in Postfix mail server, we set the correct hostname in the file “/etc/postfix/main.cf” as below:

myhostname = backup.domain.com


Likewise, in Exim mail servers, we add the hostname in exim configuration file “/etc/exim.conf” as below:

primary_hostname = backup.domain.com


b) Allow relaying of domains

Further, our Hosting Engineers specify the domain names for which the backup mail exchanger must relay emails when the primary mail server is online.

For example, in Postfix server, we mention such domains in the file “/etc/postfix/main.cf” as below:

relay_domains = domain.com


Similarly, in Exim mail server, we add the domains to be relayed in the exim config file as below:

relay_domains = domain.com


Moreover, you can specify the domain names using commas, if you want to make it as a backup mail server for multiple domains.

If the backup mail exchanger is cPanel/WHM based, we update the domain names in the file “/etc/secondarymx“.

This file maintains a list of domains for which the system serves as a backup mail exchanger.


c) Setup routing rules

Now, we need to create routing rules to tell the backup mail exchanger how to send it to the final recipient.

In Postfix server, we create the file “/etc/postfix/transportmaps” and define the routing rules as follows:

domain.com smtp:mail.domain.com


Here, domain.com is the domain from which mail originates, and the parameter smtp:mail.domain.com specifies the transport protocol and destination mail server.

Likewise, in Exim mail server, we define these routing rules under “route_list” in the exim configuration file.


d) Update the mail server DB and configuration files

Finally, rebuild the mail server database and configuration files, and restart the mail service.

In Postfix mail server, we use the postmap command to re-build the Postfix database tables.

For example:

postmap /etc/postfix/transportmaps


Then, restart the mail server. For instance, the Postfix mail service can be restarted with the command:

service postfix restart


That’s it!! Your backup mail exchanger is now ready to receive emails.

Now, let’s move on to the second step.


2) Configure low priority MX

After we’ve setup the backup mail exchanger, additional MX record should be added for the domain pointing to this backup mail server.

MX records use a weighted system. The lowest numeric MX record is considered as the primary mail server. If the primary is down, the next priority is given to the next lower value and so on.

backup mx multiple dns

MX records for a domain with backup MX


In this example, “mx1.domain.com” has priority 10 and is assigned as the primary mail server. If “mx1.domain.com” is down, mail server “mx2.domain.com” with priority 20 is selected and so on.

Here, we create a secondary MX record that point to the backup mail server with lower priority.


3) Check the retry rules in backup Mail exchanger

Next, our Hosting Engineers check the retry rules in the mail server configuration file and tweak them accordingly.

These retry rules control how often the mail server tries to deliver messages that can’t be delivered at the first attempt.

For example, in Exim servers, we manage the retry values in the exim configuration file “/etc/exim.conf”.


4) Test the backup mail exchanger setup

As soon as the secondary MX records start propagating, we validate the working of backup mail server.

For that, we stop the primary mail server and check the email logs of the backup mail server to confirm that the emails are re-routed correctly.



To sum up, the backup mail exchanger provides an uninterrupted mail service to the customers. It can also be used to load balance the mail servers. Today, we’ve seen how our Dedicated Support Engineers configure a backup mail server.


Source link


Write A Comment