OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: How to rewrite headers on a per-destination basis

From: Alex Bligh (alexalex.org.uk)
Date: Mon Nov 05 2007 - 15:09:28 CST


>> Perhaps because there is a lag between the archives
>> and when I joined postfix-users, I can't see an obvious way to only
>> invoke reformail as a content filter on certain SMTP destinations
>> (envelope to addresses).
>
> my last post was sent ... today ;-p

I subscribed today :-)

> The idea is to use a script like the one described in the FILTER_README
> (look for simple filter), and there modify the "cat |" part (or modify
> the content of in.$$).
>
> You still need to filter per recipient. This is achieved by running two
> postfix instances (running postfix twice, not just adding an smtpd
> listener to master.cf. so you need two confi directories and two queue
> directories) and use transport_maps to select the filter (so no
> content_filter setting anymore).

I was trying to get around the need for running two postfix instances by
(say) using transport_maps to send mail to example.com off to a different
filter, which was defined as an smtp transport but otherwise behaved
identically, something like in transport.maps:

  example.com filtersmtp:
  example.net filtersmtp:

then in master.cf

  filtersmtp unix - - - - - smtp -o content_filter=myfilter

  myfilter unix - n n - - pipe flags=Rq user=postfix
argv=/path/to/reformail [some flags] -- ${recipient}

... but I am not sure whether this approach would work. This would
appear to achieve the goal of filtering per recipient (well, more
accurately splitting example.com & example.net email away from other
recipients at the transport map stage), if smtp will support the
"-o content_filter" argument.

The reason I am loathe to run more than one postfix instance is
that for various reasons to do with virtual IP addresses, the box
is already running several postfix instances and I can see an O(n^2)
problem approaching, as each of the current instances will need this
hack, ahem, custom configuration.

> well, if you use perl, there is no need for reformail. something like
> this should suffice

I was trying to avoid using perl, and avoid forking on each message
too.

Alex