OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: Adding a header

From: Noel Jones (njonesmegan.vbhcs.org)
Date: Tue Jun 30 2009 - 07:37:43 CDT


Ole Tange wrote:
> I have emails with subject:
>
> Subject: blah blah [Our Ref:XXX99999]
>
> I would like to have that changed to:
>
> X-Our-Ref: XXX99999
> Subject: blah blah
>
> I can add the header with header_checks:
>
> /^Subject: .*(\[Our Ref:[A-Z]*[0-9]*\])$/ PREPEND X-Our-Ref: $1
>
> I can change the subject with header_checks:
>
> /^Subject: (.*)\[Our Ref:[A-Z]*[0-9]*\](.*)/ REPLACE Subject: $1$2
>
> But it seems I cannot do both. According to man header_checks PREPEND
> and REPLACE "inspect the next input line", which will explain why this
> does not work. As far as I can tell I cannot have 2 PREPEND acting on
> the same header.
>
> Is there a work-around for this?

Not inside postfix. As you've found, only one action is
allowed per header.

You can pass mail through postfix twice (just use postfix as a
content_filter) and do the PREPEND first time through, and
munge the Subject: the second time (requires separate cleanup
services in master.cf for different header_checks; see the
archives). If you're already using a content_filter, you get
this for free.

Maybe there's a content_filter or milter that can do what you
need; mimedefang is a first guess.

   -- Noel Jones