header_checks help, please

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

header_checks help, please

Janos Dohanics
Hello,

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:

header_checks = pcre:/usr/local/etc/postfix/header_checks.pcre

Would you please correct the error?

--
Janos Dohanics
Reply | Threaded
Open this post in threaded view
|

Re: header_checks help, please

Dominic Raferd
On Sun, 7 Oct 2018 at 21:37, Janos Dohanics <[hidden email]> 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:

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.
Reply | Threaded
Open this post in threaded view
|

Re: header_checks help, please

Noel Jones-2
On 10/7/2018 3:57 PM, Dominic Raferd wrote:

> On Sun, 7 Oct 2018 at 21:37, Janos Dohanics <[hidden email]
> <mailto:[hidden email]>> 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
Reply | Threaded
Open this post in threaded view
|

Re: header_checks help, please

Janos Dohanics
On Sun, 7 Oct 2018 16:19:32 -0500
Noel Jones <[hidden email]> wrote:

> On 10/7/2018 3:57 PM, Dominic Raferd wrote:
> > On Sun, 7 Oct 2018 at 21:37, Janos Dohanics <[hidden email]
> > <mailto:[hidden email]>> wrote:
> >
> >     I have been trying to edit the Subject: line using
> > header_checks, without success:
> >
> >     [...]
> >
> >
> > 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.

Thank you both, looks like I'll learn something new!

--
Janos Dohanics