Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Ascertaining original recipient

28 views
Skip to first unread message

Steve Crook

unread,
Jan 31, 2012, 6:28:37 AM1/31/12
to
Hi all,

I run a number of services where I use Procmail to pipe mail to an
application. The applications expect the recipient address to be passed
to them as an arguement. E.g.

:0
| application -r $RECIPIENT

I used to set $RECIPIENT in procmail using:
RECIPIENT=`formail -x X-Original-To:`
Unfortunately this isn't bulletproof as some mail arrives at my MTA with
an X-Original-To header already set. (Frequently from mailing lists)

I can configure a pipe in Postfix to do the job:
setrcpt unix - n n - - pipe
flags=DOR user=crypter argv=/usr/bin/procmail
RECIPIENT=${original_recipient}

This isn't ideal either because I need a pipe for each potential
recipient (as user=foo) is hardcoded.

One solution would be to find a way to strip any X-Original-To headers
on the message before my Postfix appends its own. The other would be to
get Postfix to set $RECIPIENT before handing the message to Procmail.
Maybe there are other options I'm missing.

Christian Winter

unread,
Feb 1, 2012, 3:37:03 PM2/1/12
to
Am 31.01.2012 12:28, schrieb Steve Crook:
[...snipped...]
> One solution would be to find a way to strip any X-Original-To headers
> on the message before my Postfix appends its own.

header_checks can do that for you. In main.cf add:
header_checks: /etc/postfix/pcre_header_checks
then create the aforementioned pcre_header_checks file with:
/^X-Original-To: (.*)/ REPLACE X-Old-Original-To: $1

Any X-Original-To header in the incoming mail will then be
rewritten into an X-Old-Original-To header.

HTH
-Chris

Steve Crook

unread,
Feb 2, 2012, 5:42:37 AM2/2/12
to
On Wed, 01 Feb 2012 21:37:03 +0100, Christian Winter wrote in
Message-Id: <4f29a272$0$7615$9b4e...@newsspool1.arcor-online.net>:

> header_checks can do that for you. In main.cf add:
> header_checks: /etc/postfix/pcre_header_checks
> then create the aforementioned pcre_header_checks file with:
> /^X-Original-To: (.*)/ REPLACE X-Old-Original-To: $1
>
> Any X-Original-To header in the incoming mail will then be
> rewritten into an X-Old-Original-To header.

Hi Chris,

That's perfect! Now I don't need a dedicated transport and can handle
everything neatly from within Procmail.

Many thanks.
Steve
0 new messages