Get a quoteGet a quote
Live ChatLive chat
Client ZoneClient Zone
ContactsContacts
Hide
Live Support
Sales department
Technical Support
Dealing with the Mail Servers fail-over

Mail Servers fail over

In case you find yourself in situation, when your email server is going down or being inaccessible due to the Internet connectivity failures, it is very likely that you will feel the need of a second email server which will queue your e-mail messages automatically, until your mail server comes back on track. Also, you can’t deny that it is essential to have the ability to read all the incoming mail and to send mail via the second mail server.

Here is what the MX Failover offers:

  • Retention of all incoming email
  • The ability to read all incoming email, which is saved locally when your main email server is down.
  • No "delivery failure reports" or "bounced messages" sent to your customers.
  • The ability to send emails via the second email server.

 

HOW TO to configure the Mail Server fail-over on EXIM

1. In order to configure the second mail server: First of all, you need to configure the second mail server with the same SMTP configuration as the main mail server. This one is required to enable receiving of all the incoming mail and to send mails.

 

2. To define MX records with different priorities

 


; zone file fragment
      IN  MX  10 mx01.example.com.
      IN  MX  20 mx02.example.com.
.... 
mx01  IN  A      192.168.0.4 
mx02  IN  A      192.169.0.5

 

3. The retention of all incoming mail.

 

Mail Server fail-over firts step

The main (mx01.example.com) mail server must have a lower priority. In our example its priority equals 10. The second (mx02.example.com) mail server must have its priority higher than the priority of mx01.If the most preferred mail server (mx01.example.com) is down or not responding, mail should be sent to the alternative server (mx02.example.com). The server mx02.example.com, as seen in the image above, is external to the domain and ideally is hosted at a separate geographic location. It must be configured as a simple relay (or forwarder) with a very long retry time (at least 2 - 7 days) in which case it will accept the mail and try and relay it to the proper destination (mx01.example.com) over the next 2 - 7 days or whatever you configure the retry time to be.

How to configure this on exim MTA: First thing is to add a route for it. Add the following lines on the text area below routers configuration:


smarthost:
	driver = manualroute
	transport = remote_smtp
	headers_add = X-Custom-Forward-remote: true
 condition = ${if match {$h_X-Custom-Forward-remote:}{true}{false}{true}}
	route_data = "mx01.example.com"

This router will redirect all the incoming messages to mx01.example.com server.

After that, you must create a system filter. Create file /etc/exim_system_filter ( by default it is defined in exim configuration,check your exim configuration file to find the correct path for system_filter file) and add this:

if first_delivery
	and $h_X-Custom-Forward-remote contains "true"
 then
   seen
   finish
endif

 

This filter is necessary in order to avoid infinite loops in case the other email server is also redirecting back to you.

4. The ability to read incoming mails if mx01 is down

Mail Server fail-over second step

Undoubtfully, it is essential to have the ability of reading all the incoming mails from mx02 in case if mx01 is down. You are supposed to configure this ability also on router level of exim configuration. In order to do this, you will need to edit the router smarhost_fallback which you will find enclosed in the fourth paragraph.

The new version of smarthos_fallback will be:


smarhost_fallback:
        driver = manualroute
        transport = remote_smtp
        headers_add = X-Custom-Forward-remote: true
        condition = ${if match {$h_X-Custom-Forward-remote:}{true}{false}{true}}
        route_data = "mx01.example.com"
        fallback_hosts = mx02.example.com 

 


 

 

This changes in smarthost_fallback will deliver all messages to mx02.example.com in case if mx01.example.com is down. Also you will want to add the second router which will forward all the messages, which were delivered to mx02.example.com to the main mail server mx01.example.com. To do this, you will have to add the following lines on the text area after smarthost_fallback router:

smarhost:
        driver = manualroute
        transport = remote_smtp
        route_data = "mx01.example.com"
unseen

 

How it works:

Mail Server fail-over: how it works

In conclusion

The exim is a very powerful and extremely customizable product. Using it, you will be able to configure a mail failover with retention of all incoming email and it will convey the ability to read all the incoming mails when the main mail server is down.

Request a Quote
Request a quote
Fill out a small form and let us contact you shortly
Client Zone
Access Client Zone
Ticket system, knowledge base and other services for our clients
Contact Us
Contact us
Send us a request or ask any questions via this contact form