I was using the sender_dependent_default_transport_maps to pick off what I 
thought was going to be the interesting from domain. The good news is that this 
mail is coming from customer applications. It's not coming from regular user 
mail clients. So I can guarantee there is going to be a single from header. The 
recipients are also never local. This machine is a pure relay.

Looks like it's time to learn me some milter. Can you recommend any good places 
to start on walking me through building one. I've got a programming background, 
so coding doesn't scare me.

Thanks again.

________________________________
From: owner-postfix-us...@postfix.org <owner-postfix-us...@postfix.org> on 
behalf of Viktor Dukhovni <postfix-us...@dukhovni.org>
Sent: Thursday, January 12, 2023 11:48 PM
To: postfix-users@postfix.org <postfix-users@postfix.org>
Subject: Re: make transport decisions based on headers not envelope

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