Postix transport smtp failover

emailpostfix

We have a multi-tenant email relay set up that has a transport map file that looks like this:

domain1.com       smtp:mail.domain1.com
domain2.com       smtp:mail.domain2.com
domain3.com       smtp:mail.domain3.com
[etc]

In the event mail.domain1.com is down, email for domain1.com will be held by the postfix server until mail.domain1.com starts responding again. However we have a customer who has a backup DSL line on their site, an their email server is also available over this. How can I tell the transport to failover to a different host if the first is unavailable?

Clarification
I think there is some confusion over the purpose of this setup. This postfix server is an inbound mail relay for clients who do not have AV and Spam protection on site. It is one of a pair, which are configured as the 2 MX records for these customers. They receive and clean email before forwarding it on to their local mail servers, as well as acting as a buffer in case of an outage on their end. These customers don't generally have multiple on site mail servers, they are too small hence this service. What they do often have though is a secondary connection, eg fibre and DSL, so I'd like to be able to direct the onward SMTP to their second connection should the first be unreachable.

Best Answer

You can add a failover server declaring a new MX DNS record pointing to the failover IP (I guess the server external IP will change if it's NATed behind a DSL line).

The new MX record will have a lower weight value that the default MX record, which will prevent from using it when the default/main server is reachable

Related Topic