[pfx] Re: Subject modification based on recipient
On 28/04/23 21:19, Andreas Cieslak via Postfix-users wrote: Why are To and From replaced in the header but not the subject? Am I perhaps missing the right expression here and could someone give me some advice? Or is there really no way around Mailmunge or MimeDefang etc.? Any hints would be appreciated. Others have already answered this. header_checks operates on only ONE HEADER AT A TIME. If you match the To: header then the REPLACE operation replaces the To: header with whatever you put in the replacement text, so when you are trying to replace the Subject header you are literally replacing the To: header in the message with a second Subject: line thereby resulting in a message with no To: header and two Subject: headers. The way that this is treated in the email client is very much undefined. The only way to accomplish what you want is with either a milter or a content filter. Peter ___ Postfix-users mailing list -- postfix-users@postfix.org To unsubscribe send an email to postfix-users-le...@postfix.org
[pfx] Re: Subject modification based on recipient
Thanks for your replies. Meanwhile i have tested with some simple replacements in header checks. /email@office/ REPLACE From: Office /email@hospital/ REPLACE From: Hospital With the above, the replacement works fine for multiple lines. Here are the logs: Apr 28 10:40:10 server postfix/smtpd[48572]: connect from unknown[remote system IP] Apr 28 10:40:10 server postfix/smtpd[48572]: 381C760324: client=unknown[remote system IP] Apr 28 10:40:10 server postfix/cleanup[48576]: 381C760324: message-id=<1682671210.212@company> Apr 28 10:40:10 server postfix/qmgr[48571]: 381C760324: from=, size=600, nrcpt=1 (queue active) Apr 28 10:40:10 server postfix/smtpd[48572]: disconnect from unknown[remote system IP] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5 Apr 28 10:40:10 server postfix/smtp[48577]: 381C760324: replace: header Received: from company (unknown [remote system IP])??by hres: From: Office Apr 28 10:40:10 server postfix/smtp[48577]: 381C760324: replace: header To: email@office: From: Office Apr 28 10:40:10 server postfix/smtp[48577]: 381C760324: to=, orig_to=, relay=smtp.company.net[IP]:25, delay=0.25, delays=0.01/0 Anyway, the final result i want to achieve, is that the Subject will be filled with the RCPT To header part,like this /email@office/ REPLACE Subject: Office /email@hospital/ REPLACE Subject: Hospital But the replacement is not working. The received emails shows an unmodified Subject but the RCPT To field is empty. Apr 28 10:40:10 server postfix/smtpd[48572]: connect from unknown[remote system IP] Apr 28 10:40:10 server postfix/smtpd[48572]: 381C760324: client=unknown[remote system IP] Apr 28 10:40:10 server postfix/cleanup[48576]: 381C760324: message-id=<1682671210.212@company> Apr 28 10:40:10 server postfix/qmgr[48571]: 381C760324: from=, size=600, nrcpt=1 (queue active) Apr 28 10:40:10 server postfix/smtpd[48572]: disconnect from unknown[remote system IP] ehlo=1 mail=1 rcpt=1 data=1 quit=1 commands=5 Apr 28 10:40:10 server postfix/smtp[48577]: 381C760324: replace: header Received: from company (unknown [remote system IP])??by hres: Subject: Office Apr 28 10:48:44 hreslb03 postfix/smtp[48602]: 9D1A160324: replace: header To: email@office: Subject: Office Apr 28 10:40:10 server postfix/smtp[48577]: 381C760324: to=, orig_to=, relay=smtp.company.net[IP]:25, delay=0.25, delays=0.01/0 Why are To and From replaced in the header but not the subject? Am I perhaps missing the right expression here and could someone give me some advice? Or is there really no way around Mailmunge or MimeDefang etc.? Any hints would be appreciated. Thank you. Am Mi., 26. Apr. 2023 um 17:25 Uhr schrieb Wietse Venema via Postfix-users < postfix-users@postfix.org>: > Wietse Venema via Postfix-users: > > Andreas Cieslak via Postfix-users: > > > 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. > > > > Suggestion: use milter-regex. You can install it from source code, > > or install as a package for many distributions. > > Unfortunately, it looks like milter-regex is good for rejecting > mail, not for message modification. > > Wietse > ___ > Postfix-users mailing list -- postfix-users@postfix.org > To unsubscribe send an email to postfix-users-le...@postfix.org > ___ Postfix-users mailing list -- postfix-users@postfix.org To unsubscribe send an email to postfix-users-le...@postfix.org
[pfx] Re: Subject modification based on recipient
Wietse Venema via Postfix-users: > Andreas Cieslak via Postfix-users: > > 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. > > Suggestion: use milter-regex. You can install it from source code, > or install as a package for many distributions. Unfortunately, it looks like milter-regex is good for rejecting mail, not for message modification. Wietse ___ Postfix-users mailing list -- postfix-users@postfix.org To unsubscribe send an email to postfix-users-le...@postfix.org
[pfx] Re: Subject modification based on recipient
Andreas Cieslak via Postfix-users: > 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. Suggestion: use milter-regex. You can install it from source code, or install as a package for many distributions. Wietse ___ Postfix-users mailing list -- postfix-users@postfix.org To unsubscribe send an email to postfix-users-le...@postfix.org
[pfx] Re: Subject modification based on recipient
On 2023-04-26 at 10:07:09 UTC-0400 (Wed, 26 Apr 2023 16:07:09 +0200) Andreas Cieslak via Postfix-users 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