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 protected]). 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:
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.
Hi. Another great tutorial! I’m going to do it to create a backup mail server. But because this will me a small VPS i need to reduce CPU and RAM usage as most as possible. The VPS will be only used as Backup MX and I run my DNS on a external provider. So can you help me out and tell me what services can I disable:
FTP
LFD
Exim
Dovecot
SpamAssassin
NGINX
DNS-Server
PHP-FPM
Vesta-NGINX
Vesta-PHP
MariaDB
Thanks!
Hi António,
You can disable them all except you need to keep Exim. VestaCP does not need to be installed on this server.
2) I’ve never placed my secondary server’s IP in the SPF – the reason is because this secondary server should only be sending emails back to your main server. It’s not to be used to send to external mail servers.
3) You’ll want to keep the SpamAssassin on this server to scan the emails again, and you can remove SA from the secondary server. This server is only ever used if the primary one goes offline however, some spam-bots etc still do send to the secondary email server.
Thanks for the advice!
Just to be clear your advice is to disable SpamAssassin on the Primary Mail Server or on the Secondary MX Backup server? My idea is to disable on the Secondary MX Backup server.
Thanks
Yup – it can be removed from the secondary server.