Score:0

Postfix transport map with failover entries?

eg flag

Postfix relays a few domains to a fixed IP address, or its failover address.

1.2.3.4 and 11.12.13.14 (failover)

These two IP addresses are where the relay should occur.

Currently, transport_map

exemple1.com   relay:[1.2.3.4]:587
exemple2.com   relay:[1.2.3.4]:587

Is there a way, in case [1.2.3.4] times out, to use the failover automatically, like

exemple1.com   relay:[1.2.3.4]:587
exemple2.com   relay:[1.2.3.4]:587
exemple1.com   relay:[11.12.13.14]:587
exemple2.com   relay:[11.12.13.14]:587

Would that work?

(There is this question which is a tad different. Adding multiple IPs to /etc/hosts (or DNS if that was possible) would use either IP. In my case the failover should only be used if the main one times out)

Nikita Kipriyanov avatar
za flag
The [`transport (5) man page`](http://www.postfix.org/transport.5.html) says: *In the сase of the Postfix SMTP/LMTP client, the nexthop field may contain a list of nexthop destinations separated by comma or whitespace (Postfix 3.5 and later).* No further explanation is given about interpretation of such token. Probably it's worth asking in the Postfix users mailing list.
eg flag
Great, thanks. We're on Postfix 3.3 (Ubuntu 18.04 LTS) though.
csx4 avatar
cn flag
so did it work ? how did you write like this ? exemple1.com relay:[1.2.3.4]:587,relay:[11.12.13.14]:587 exemple2.com relay:[1.2.3.4]:587,relay:[11.12.13.14]:587
Score:1
jp flag

Excerpt from Postfix 3.5 release notes

[Feature 20200111] the Postfix SMTP and LMTP client support a list of nexthop destinations separated by comma or whitespace. These destinations will be tried in the specified order.

The list form can be specified in relayhost, transport_maps, default_transport, and sender_dependent_default_transport_maps.

Examples:

/etc/postfix/main.cf:
    relayhost = foo.example, bar.example
    default_transport = smtp:foo.example, bar.example.

NOTE: this is an SMTP and LMTP client feature. It does not work for other Postfix delivery agents.

If you don't have Postfix 3.5 you can specify the destination as a domain name without brakets - postfix will do MX lookups for that domain name and use MX to send the email.

eg flag
Will this work with the `relay:` prefix in transport (syntax in the question). Like `exemple1.com relay:myMxDnsEntriesHost:587` ? If yes, that's a great idea, as MX includes priorities!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.