DevHeads.net

Adding a header

I have emails with subject:

I would like to have that changed to:

X-Our-Ref: XXX99999

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?

/Ole

Comments

Re: Adding a header

By LuKreme at 07/01/2009 - 02:11

Run it through procmail, it's trivial.

Re: Adding a header

By Noel Jones at 06/30/2009 - 08:37

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