0

We're using 3rd-party relays for some of the external domains. For example, a snippet from /etc/mail/mailertable may look like:

example.com    relay:[smtp.example.net]:587
example.co.uk  relay:[mail.example.org]:587

and I'd like to stack them for redundancy: if, for any reason, one relay refuses to accept a message, sendmail should automatically try another one.

Can the above example be rewritten so that both relays may be used for both domains? Something like:

example.com    relay:[smtp.example.net,mail.example.org]:587
example.co.uk  relay:[mail.example.org,smtp.example.net]:587

perhaps?

Ideally, the next relay would be tried even if the earlier one(s) replied with a 5xx...

Mikhail T.
  • 2,405

1 Answers1

0

The default approach in SMTP for mailservers to provide redundancy and failover is via MX records in DNS.

The native built in method is already to try every MX record in order until either the message is accepted for delivery, a hard rejection is received until all MX records have been attempted. If none of the MX records definitively accepted/ rejected the message (due to transient errors or no connectivity) then the message is queued for a later delivery attempt or until sendmail gives up.

When you don’t disable MX lookups by enclosing the relays in square brackets [ ] and not only A records but also multiple MX records have been configured for your third party relays smtp.example.net and mail.example.org you immediately get what you want by using a mailertable

example.com    relay:smtp.example.net:587
example.co.uk  relay:mail.example.org:587

If there are no MX records setup yet you can create them and when you don’t manage the example.net and example.org domains, you can even use a completely different unrelated subdomain of your own (that you do control) for that.

example.com.mailertable.contoso.com. IN MX 1 smtp.example.net.
example.com.mailertable.contoso.com. IN MX 2 mail.example.org.

and then a mailertable

example.com    relay:example.com.mailertable.contoso.com:587
HBruijn
  • 84,206
  • 24
  • 145
  • 224