DevHeads.net

sender AND recipient based routing

I have a requirement to deliver via 'X' when sender = 'A' /and/ recipient =
'B', else deliver via configured defaults.
I see how I could use sender_dependent_default_transport_maps to set nexthop
to 'X' when sender = 'A' but I still need to deal with the additional
condition that recipient = 'B'.
It's like I need multiple transport tables, dependent upon sender.
Is there any way to fulfill this requirement within the postfix framework?

Comments

Re: sender AND recipient based routing

By Viktor Dukhovni at 02/12/2018 - 13:37

Not within a single Postfix instance. With multiple instances (and much
complexity) you could use "sender A" select a different downstream instance,
where B is routed to the desired transport. This scales poorly, but if the
exceptions are few enough, and the need great, then you can do it.

Another option is to use a proxy filter, or milter to rewrite B to some
special recipient address B' when the sender is A, then route B' to a
custom nexthop, and use smtp_generic_maps to transform B' back to B
on output. This works in a single Postfix instance with a proxy filter
or milter.

Re: sender AND recipient based routing

By flymike at 02/12/2018 - 15:27

Thanks, Viktor.
With the milter option, can I still use transport_maps to set the custom
nexthop? I'm wondering if smtp_generic_maps are applied after or before
transport_maps?

Re: sender AND recipient based routing

By Viktor Dukhovni at 02/12/2018 - 16:06

Yes.

Milters happen on input when messages are received, transport
lookups when messages enter the active queue, and smtp_generic_maps
(naturally) on output, in the SMTP delivery agent.