On 8/27/2020 5:58 AM, Gregory Heytings wrote:
My Postfix server handles message for a dozen domains, for one of
these domains, I want the subject replaced with the recipient's local
part, so something like this, but put in a format that Postfix
understands:
# domain3.com is the one recipient domain we want affected by this
rule # $recipient_name the recipient localpart, so "joe" if the
recipient is # j...@domain3.com
IF $recipient_domain = 'domain3.com'
REPLACE $subject WITH $recipient_name
ENDIF
I think I need to setup a smtp_header_checks file, but the more I
look at it the harder my head hurts.
That's not possible alas, see the section BUGS at
http://www.postfix.org/header_checks.5.html : "Many people overlook
the main limitations of header and body_checks rules. These rules
operate on one logical message header or one body line at a time. A
decision made for one line is not carried over to the next line."
IOW, the only things you can do with smtp_header_checks is to replace
a Subject: line with another Subject: line, possibly based on the
contents of the original Subject: line if you use regexp
backreferences. But there is no way to use the recipient name or
domain in such rules.
For cases like the one you have in mind, it is necessary to use a milter.
Gregory
Thank you for saving me some head scratching. It wouldn't be the end of
the world to spin up an Exim VM (its system_filtering is capable of this
black magic), but would prefer staying in Postfix.
Do you have a milter in mind for this task?