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

Adding a dynamic header to all mail passing through Postfix

2,779 views
Skip to first unread message

Mark Goodge

unread,
Nov 22, 2011, 5:51:27 AM11/22/11
to
I am suffering from AOL numpties who click "this is spam" on
notification emails they get (by their request!) from a forum and
mailing list hosted on my server. In order to trap these, I've set up a
feedback loop with AOL so that I'm notified when anybody does that.

However, AOL's feedback system removes the recipient email address, so I
can't identify the complainer from the report. So what I need to do is
add a custom header to every outbound mail from my server which
identifies the recipient address.

Of course, one way to do this would be to set the header in the software
which generates the mail. But this is impractical for several reasons:
Firstly, there is more than one package on the server which sends mail,
so all of them would need to be changed, and, secondly, I didn't write
any of them so it not only means editing someone else's code but also
re-applying the edit any time I upgrade.

What I'd like to do, therefore, is set a header via Postfix. But I am
having difficulty working out how to do that, or even if it's possible.

I already have a line in main.cf for header checks:

header_checks = regexp:/etc/postfix/header_checks_regex

so I started from the assumption that I ought to be able to simply add a
line to that which matches everything and use that to add the header:

/./ PREPEND X-Test-Header: yes

Now, that works OK. But what I want to do is to be able to replace the
header value in each mail with a custom value derived from the mail
itself, using some kind of lookup or replacement method - something like

/./ PREPEND X-Test-Header: ${user}

So my question is: is there any way to do this? If so, how? Or am I
barking up completely the wrong tree here?

Mark
--
Sent from my Babbage Difference Engine
http://mark.goodge.co.uk
http://www.ratemysupermarket.com

Jerry

unread,
Nov 22, 2011, 6:22:28 AM11/22/11
to
On Tue, 22 Nov 2011 10:51:27 +0000
Mark Goodge articulated:

> I am suffering from AOL numpties who click "this is spam" on
> notification emails they get (by their request!) from a forum and
> mailing list hosted on my server. In order to trap these, I've set up
> a feedback loop with AOL so that I'm notified when anybody does that.
>
> However, AOL's feedback system removes the recipient email address,
> so I can't identify the complainer from the report. So what I need to
> do is add a custom header to every outbound mail from my server which
> identifies the recipient address.

Wouldn't VERP be what you are looking for?

http://www.postfix.com/VERP_README.html

--
Jerry ✌
postfi...@seibercom.net
_____________________________________________________________________
TO REPORT A PROBLEM see http://www.postfix.org/DEBUG_README.html#mail
TO (UN)SUBSCRIBE see http://www.postfix.org/lists.html

Ralf Hildebrandt

unread,
Nov 22, 2011, 6:35:04 AM11/22/11
to
* Mark Goodge <ma...@good-stuff.co.uk>:
> I am suffering from AOL numpties who click "this is spam" on
> notification emails they get (by their request!) from a forum and
> mailing list hosted on my server. In order to trap these, I've set up
> a feedback loop with AOL so that I'm notified when anybody does that.

Been there, done that

> However, AOL's feedback system removes the recipient email address,
> so I can't identify the complainer from the report. So what I need to
> do is add a custom header to every outbound mail from my server which
> identifies the recipient address.

Simply make your lists use VERP and this problem is solved!

--
Ralf Hildebrandt
Geschäftsbereich IT | Abteilung Netzwerk
Charité - Universitätsmedizin Berlin
Campus Benjamin Franklin
Hindenburgdamm 30 | D-12203 Berlin
Tel. +49 30 450 570 155 | Fax: +49 30 450 570 962
ralf.hil...@charite.de | http://www.charite.de


Wietse Venema

unread,
Nov 22, 2011, 8:20:34 AM11/22/11
to
Mark Goodge:
> I am suffering from AOL numpties who click "this is spam" on
> notification emails they get (by their request!) from a forum and
> mailing list hosted on my server. In order to trap these, I've set up a
> feedback loop with AOL so that I'm notified when anybody does that.
>
> However, AOL's feedback system removes the recipient email address, so I
> can't identify the complainer from the report. So what I need to do is
> add a custom header to every outbound mail from my server which
> identifies the recipient address.
>
> Of course, one way to do this would be to set the header in the software
> which generates the mail. But this is impractical for several reasons:
> Firstly, there is more than one package on the server which sends mail,
> so all of them would need to be changed, and, secondly, I didn't write
> any of them so it not only means editing someone else's code but also
> re-applying the edit any time I upgrade.
>
> What I'd like to do, therefore, is set a header via Postfix. But I am
> having difficulty working out how to do that, or even if it's possible.

First, you must send one recipient per message, otherwise you still
won't know who the recipient was when you get feedback from AOL.

Once you have one recipient per message, prepend the recipient with
check_recipient_access:

/etc/postfix/main.cf:
smtpd_XXX_restrictions =
check_recipient_access pcre:/etc/postfix/prepend.pcre

/etc/postfix/rcpt_prepend.pcre:
/(.+)/ prepend X-YYY: $1

For suitable values of XXX and YYY.

Or use VERP, as others have suggested.

Wietse

Mark Goodge

unread,
Nov 22, 2011, 8:23:58 AM11/22/11
to
On 22/11/2011 13:20, Wietse Venema wrote:
> Mark Goodge:

>> What I'd like to do, therefore, is set a header via Postfix. But I am
>> having difficulty working out how to do that, or even if it's possible.
>
> First, you must send one recipient per message, otherwise you still
> won't know who the recipient was when you get feedback from AOL.
>
> Once you have one recipient per message, prepend the recipient with
> check_recipient_access:
>
> /etc/postfix/main.cf:
> smtpd_XXX_restrictions =
> check_recipient_access pcre:/etc/postfix/prepend.pcre
>
> /etc/postfix/rcpt_prepend.pcre:
> /(.+)/ prepend X-YYY: $1
>
> For suitable values of XXX and YYY.
>
> Or use VERP, as others have suggested.

Thanks. I'll investigate both options, and see which is best suited to
my needs.

Brian Evans - Postfix List

unread,
Nov 22, 2011, 8:53:30 AM11/22/11
to
On 11/22/2011 6:35 AM, Ralf Hildebrandt wrote:
> * Mark Goodge <ma...@good-stuff.co.uk>:
>> I am suffering from AOL numpties who click "this is spam" on
>> notification emails they get (by their request!) from a forum and
>> mailing list hosted on my server. In order to trap these, I've set up
>> a feedback loop with AOL so that I'm notified when anybody does that.
> Been there, done that
>
>> However, AOL's feedback system removes the recipient email address,
>> so I can't identify the complainer from the report. So what I need to
>> do is add a custom header to every outbound mail from my server which
>> identifies the recipient address.
> Simply make your lists use VERP and this problem is solved!
>

In regards to the OP's issue for this case, AOL also will obfuscate a
VERP address in its report.
So a non-email based header may be the only option.

Wietse Venema

unread,
Nov 22, 2011, 8:53:52 AM11/22/11
to
Mark Goodge:
> On 22/11/2011 13:20, Wietse Venema wrote:
> > Mark Goodge:
>
> >> What I'd like to do, therefore, is set a header via Postfix. But I am
> >> having difficulty working out how to do that, or even if it's possible.
Wietse:
[prepending recipient header at SMTP time].
> > Or use VERP, as others have suggested.
>
> Thanks. I'll investigate both options, and see which is best suited to
> my needs.

One more thing.

You can use the smtpd_command_filter feature to append XVERP to
SMTP commands from legacy sofware. This requires Postfix 2.7 or
later.

/etc/postfix/main.cf:
smtpd_command_filter = pcre:/etc/postfix/append_verp.pcre
smtpd_authorized_verp_clients = $mynetworks

/etc/postfix/append_verp.pcre:
/^(MAIL FROM:<listname@example\.com$>.*)/ $1 XVERP

I just added this note to VERP_README.

Wietse

Ralf Hildebrandt

unread,
Nov 22, 2011, 8:54:24 AM11/22/11
to
> In regards to the OP's issue for this case, AOL also will obfuscate a
> VERP address in its report.

Not enough :)
On python.org I still can identify the original recipients.

Wolfgang Zeikat

unread,
Nov 22, 2011, 9:03:21 AM11/22/11
to


In an older episode, on 2011-11-22 11:51, Mark Goodge wrote:
> However, AOL's feedback system removes the recipient email address, so I
> can't identify the complainer from the report.

It does not remove your server's header lines though, including
message-ID and postfix queue ids, so you can find the information in
your outgoing server's logs.

Hope this helps,

wolfgang

Ralf Hildebrandt

unread,
Nov 22, 2011, 9:04:56 AM11/22/11
to
* Wolfgang Zeikat <wolfgan...@desy.de>:
Exactly.

Mark Goodge

unread,
Nov 22, 2011, 9:25:50 AM11/22/11
to
On 22/11/2011 14:03, Wolfgang Zeikat wrote:
>
>
> In an older episode, on 2011-11-22 11:51, Mark Goodge wrote:
>> However, AOL's feedback system removes the recipient email address, so
>> I can't identify the complainer from the report.
>
> It does not remove your server's header lines though, including
> message-ID and postfix queue ids, so you can find the information in
> your outgoing server's logs.

Indeed, but that adds an extra layer of effort to the process, and isn't
always practical if a report comes in when I don't have direct access to
the server. If someone is stupid enough to sign up to a forum and then
hit the spam button when the forum sends them a notification, I just
want to delete their membership via the web interface without any extra
faffing around.

Wietse Venema

unread,
Nov 22, 2011, 11:41:04 AM11/22/11
to
Wietse Venema:
> You can use the smtpd_command_filter feature to append XVERP to
> SMTP commands from legacy sofware. This requires Postfix 2.7 or
> later.
>
> /etc/postfix/main.cf:
> smtpd_command_filter = pcre:/etc/postfix/append_verp.pcre
> smtpd_authorized_verp_clients = $mynetworks
>
> /etc/postfix/append_verp.pcre:
> /^(MAIL FROM:<listname@example\.com$>.*)/ $1 XVERP

That "$" before ">" should be removed.

Wietse
0 new messages