On 2023-04-26 at 10:07:09 UTC-0400 (Wed, 26 Apr 2023 16:07:09 +0200)
Andreas Cieslak via Postfix-users <ace....@gmail.com>
is rumored to have said:

Hi list,

i want to achieve that my postfix relay will modify the subject based on
the recipients.
The postfiy relay is receiving email from other internal systems and
forwards all mail to a mail group (testgroup) on another internal mail
system.

I have already configured the following in the header_checks file
if !/^To: email@company$/
/^Subject: (.+)$/i REPLACE Subject: [email@company] $1
endif
For this one case it works fine.

Now i want to modify the subject for more emails in the header_checks like
if !/^To: email@company$/
/^Subject: (.+)$/i REPLACE Subject: [email@company] $1
endif
if !/^To: email@company2$/
/^Subject: (.+)$/i REPLACE Subject: [email@company2] $1
endif

I have read that there is a header_checks limitation for the first line
check, so my example does not work.

Correct. The header_checks facility checks exactly one header at a time, so there is NO WAY to make the above logic work using header_checks. When header_checks is examining the To header, it is ONLY able to operate on the To header. The 'if/endif' structure is primarily useful to make sure some rules are only ever applied to specific headers and skipped for others.

Does anybody know if its possible with regex within header_checks?
Or is there another possibility to solve this?

You would need to use a milter or a content_filter for this. For example, MIMEDefang (or its descendant MailMunge) could do this in a filter_end() subroutine.


--
Bill Cole
b...@scconsult.com or billc...@apache.org
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)
Not Currently Available For Hire
_______________________________________________
Postfix-users mailing list -- postfix-users@postfix.org
To unsubscribe send an email to postfix-users-le...@postfix.org

Reply via email to