On 10/7/2018 3:57 PM, Dominic Raferd wrote: > On Sun, 7 Oct 2018 at 21:37, Janos Dohanics <w...@3dresearch.com > <mailto:w...@3dresearch.com>> wrote: > > I have been trying to edit the Subject: line using header_checks, > without success: > > header_checks.pcre: > > if /^From: (.*)<(.+)mydomain\.com\>$/i > /^Subject: (.*)$/i > REPLACE Subject: some_string $1 > endif > > main.cf <http://main.cf>: > > header_checks = pcre:/usr/local/etc/postfix/header_checks.pcre > > > I don't know how this can be done by postfix. See > http://www.postfix.org/header_checks.5.html - header lines are > inspected one at a time and you can only take action on the one > header line that is being inspected. To do what you want - rewrite > subject depending on 'To:' I think you need a suitable milter. I'm > sure someone more experienced than me can suggest one.
Dominic is correct, postfix header_checks operates on one header at a time, and doesn't save state between headers. You'll need a milter or other external filter. regex-milter is a fairly simple milter often recommended for things such as this. MIMEDefang is a more complex milter that can alter subjects, plus many more features. -- Noel Jones