How to mark a mail domain as backup MX


Check out the lightweight on-premises email archiving software developed by iRedMail team: Spider Email Archiver.

This tutorial describes how to mark a mail domain as a backup MX.

How backup MX works in brief

When smtp service on primary MX server is down, emails will be delivered to backup MX server. When backup MX server detects smtp service on primary MX is back online, it will relay received emails to primary MX.

Make sure you have correct DNS records for the mail domain

To let other mail servers know your server is the backup MX server of this mail domain, you must add your mail server info in its MX type DNS record.

For example, main mail server of your mail domain is, to set your iRedMail server as backup MX of, you need to add as your lower priority mail server in MX type DNS record.    3600    IN  MX  5    3600    IN  MX  10

Server has priority number 5, and has priority number 10. For mail service, the lowest number has highest priority. so with above example, server is the primary MX, and is a backup MX.

When mail service on is down, other mail services will connect to

Mark domain as backup MX with iRedAdmin-Pro

It's easy to manage domain profile With iRedAdmin-Pro, including backup MX setting. Go to domain profile page, click tab Backup MX:

Mark domain as backup MX with command line tools

For SQL backends

Primary server address

It's recommended to set the IP address of primary MX as relay server to avoid mail loop.

SQL commands (we use MySQL for example):

USE vmail;
UPDATE domain SET transport='relay:[]:25',backupmx=1 WHERE domain='';

In above example, we mark domain as a backup MX, and use IP address as primary MX server, you should replace it by the real IP address.

For LDAP backends

In domain object, please add LDAP attribute/value pair like below:

domainBackupMX: yes
mtaTransport: relay:[]:25

See also