4

I want to have a list of hosts in relayhost, and when postfix tries to send an email, it sends it to any of them, and if that one is offline, it tries another one.

Can it be done in the config-file, or do I need to play with DNS-settings?
if I give relayhost a made-up hostname that have multiple mx records, will it try all?
If I give relayhost a made-up [hostname] that have multiple a records, how will it handle it?

ref: http://www.postfix.org/postconf.5.html#relayhost

5

Postfix doesn't allow defining multiple entries for relayhosts for redundancy. Have a look at the page you have referenced:

In the case of SMTP, specify a domain name, hostname, hostname:port, [hostname]:port, [hostaddress] or [hostaddress]:port. The form [hostname] turns off MX lookups.

As you can see, there is no way to define multiple addresses/hostnames here.

if I give relayhost a made-up hostname that have multiple mx records, will it try all?

I guess so, but if it requires authentication, then it may not work with the secondary server anyway and fail.

If I give relayhost a made-up [hostname] that have multiple a records, how will it handle it?

It will use the first address (A record) returned by the dns in round robin method. But this also doesn't imply that it will try another one in case the one returned by the dns server fails.

Having said that, you may have a look at this postfix option: smtp_fallback_relay

| improve this answer | |
  • The smtp_fallback_relay was a great help! I have redundant WAN links and often DNS has issues when the link fails over so using this tip I was able to make email delivery more robust with these tweaks: /etc/postfix/main.cf relayhost = [smtp.gmail.com]:587 smtp_fallback_relay = [74.125.28.108]:587 /etc/postfix/sasl_passwd [smtp.gmail.com]:587 user@gmail.com:password​ ​[74.125.28.108]:587 user@gmail.com:password​ – Andrew S Jun 14 '17 at 14:52
3

I would recommend to go with DNS.

But you don't need to set multiple MX records - you need to resolve the given hostname with multiple A-Records (host should resolve to a given set ip addresses).

Having multiple hosts to handle traffic is quite common for mail. This is done using multiple mx records. So it's just straight forward when you'll use the same setup when sending from your own host/relay.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.