On Fri, Jan 13, 2023 at 03:22:41AM +0000, Sean Hennessey wrote:

> I'm back to the experts for some question. I'm trying to help dig some
> folks out of hole. Is there anyway possible to make a decision on
> where to send mail based on a friendly from header instead of the
> envelope from?

NO! That way lies madness and endless mail loops.  Or, more precisely,
absolutely not when deciding which way to route the *recipients* of
the message.

> It turns out that their system using an envelope from that's the same
> for everyone, and just uses the customer specific from in the From:
> header. That's probably the better thing to be doing, but it just
> burnt me because the system I'm most recently working on matches
> aligns the envelope from and the header from.

Presumably, this is a case of trying to use:

    sender_dependendent_default_transport_maps

this could in principle be based on the "From:" header without risking
loops, however there's no such feature in Postfix, and there are various
potential complications:

    - What happens when there's both a "Sender:" and a "From:" header?
    - What happens when "Resent-From:" is present?
    - What happens in the unusual case where there are multiple "From:"
      addresses (allowed by RFC822, with "Sender:" required).
    - What happens when there is no "From:" header?  (And Postfix adds
      "Apparently-From: <envelope-sender>").
    - ...

So, provided the accepted recipients are *NEVER EVER* local or any other
address class, you'd want to use a milter to prepend a header that
indicates the exit transport, and then use milter_header_checks to
specify a "FILTER" action that forces all recipients to that transport.

This is a bit ugly, but puts the ball in your court (all the messy
details are in your milter, whatever you decide goes).  Don't forget,
the precondition, there must never be any recipients in any address
class other than "default" or else routing will be wrong.

-- 
    Viktor.

Reply via email to