Backup MX / Backup Email / Secondary MX Server – VestaCP

Hey guys,

I found a great little tutorial from me back on the VestaCP forums in April 2016 regarding a Secondary MX (backup email server) server for VestaCP – it’s really easy to set up. Essentially what happens is when your main email server is offline or under stress, the third party email server (the one sending the email) sends the email to the secondary email server. Once that happens, the secondary email server attempts to send the email back to the first email server.

Read on for more information.

How to set up a Secondary MX (email) server on VestaCP

This tutorial is for CentOS – but you should know where your exim config files are on other OS.

1) First set-up the second server (can be a separate install of Vesta or just a stripped down version) with VestaCP. Make sure it’s got Exim installed.

2) Create a file /etc/exim/mx_domains on the second server and populate it with the domains separated by a new line you want it to accept mail for. (i.e. yourdomain.com)
Example:

domain1.com
domain2.co.uk

3) Change the file  /etc/exim/exim.conf  (on the second server) and find the line  domainlist relay_to_domains = dsearch;/etc/exim/domains/  and change it to domainlist relay_to_domains = dsearch;/etc/exim/domains/ : lsearch;/etc/exim/mx_domains

4) Restart Exim on the second server.

5) Go to https://www.wormly.com/test_smtp_server and send a test email (i.e. email@domain2.co.uk). Make sure the SMTP Server field is the IP address of your second VestaCP server.

6) It should report it’s been accepted, and then after a short while you should receive the test e-mail to your main mail server.

7) If testing succeeded and you receive the e-mail, you can now set-up the second MX record with a higher priority (i.e. 20) in VestaCP under the DNS section of the domain name like so:

Secondary MX

Note: mx1.domain.com and mx2.domain.com should resolve to IP addresses of the email servers. mx1 being the first email server, and mx2 being the secondary email server.