From: Fitzgerald on
Hi there!

Currently I am looking for a way to implement a bounce handler and I would
like some 'best practices' advice. I have very little experience in using
postfix but I came up with some ideas and want to get some comments on
those.

An application sends out a bunch of e-mails with a varying return path
(VERP) of the form bounce-some_identifier(a)mydomain.tld where
some_identifier is a unique and random string. My idea is to have a python
bouncehandler script that will parse all bounces and notify the application
that certain e-mails did not arrive at their destination.

To complete the puzzle I need the following:
1. Postfix needs to accept mail of the form
bounce-some_identifier(a)mydomain.tld
2. Postfix needs to deliver this mail to a unix socket where the python
bouncehandler is listening
3. The delivery of 2 is handled according to a certain protocol or
specification

For point [1] I guess the most easy way is to use regular expressions
(PCRE) as mappings. I haven't looked into this yet, but I guess it
shouldn't be that hard. Other mail for the same domain has to undergo
'normal delivery'. Links to good examples are welcome. For point [2] I
think I need to add a line to master.cf and I need to tell Postfix to use
this delivery agent for the matches of [1]. Finally (and on this I really
would like some advice) this delivery has to be done in a certain way. For
example directly passing the message like a pipe or maybe something more
elaborate like using LMTP as a delivery protocol.

What would you recommend? And, if you have some examples lying around of
something similar setups/configurations, sharing this information would be
greatly appreciated!

Thanks in advance!

David

From: =?UTF-8?B?U3TDqXBoYW5lIE1FUkxF?= on
Hi,

Fitzgerald a écrit :
> Hi there!
>
> Currently I am looking for a way to implement a bounce handler and I would
> like some 'best practices' advice. I have very little experience in using
> postfix but I came up with some ideas and want to get some comments on
> those.
>
> An application sends out a bunch of e-mails with a varying return path
> (VERP) of the form bounce-some_identifier(a)mydomain.tld where
> some_identifier is a unique and random string. My idea is to have a python
> bouncehandler script that will parse all bounces and notify the application
> that certain e-mails did not arrive at their destination.
>
why using a bouncehandler ? you just have to parse the log file to find
out which VERP had been bounced .... you may have to match differents
lines with the id but it's working quite well, without interfering with
the postfix work ...

Stéphane

From: Noel Jones on
On 3/15/2010 8:59 AM, Fitzgerald wrote:
> Hi there!
>
> Currently I am looking for a way to implement a bounce handler and I would
> like some 'best practices' advice. I have very little experience in using
> postfix but I came up with some ideas and want to get some comments on
> those.
>
> An application sends out a bunch of e-mails with a varying return path
> (VERP) of the form bounce-some_identifier(a)mydomain.tld where
> some_identifier is a unique and random string. My idea is to have a python
> bouncehandler script that will parse all bounces and notify the application
> that certain e-mails did not arrive at their destination.
>
> To complete the puzzle I need the following:
> 1. Postfix needs to accept mail of the form
> bounce-some_identifier(a)mydomain.tld

Use main.cf
recipient_delimiter = -
to accept all mail to bounce-*@example.com
http://www.postfix.org/postconf.5.html#recipient_delimiter

It's more common to use "+" as both recipient_delimiter and
the VERP separator, but use whichever works better for you.
Either should be OK as long as you use the same separator in
both places.

> 2. Postfix needs to deliver this mail to a unix socket where the python
> bouncehandler is listening

Define a pipe transport in master.cf that delivers to your
python application. See several examples in master.cf and also
http://www.postfix.org/pipe.8.html

Then use a transport_maps entry to direct the bounce mail to
that transport (assuming a master.cf transport named
pybounce). Something like
# main.cf:
transport_maps = hash:/etc/postfix/transport

# /etc/postfix/transport
bounce(a)example.com pybounce:
http://www.postfix.org/transport.5.html

> 3. The delivery of 2 is handled according to a certain protocol or
> specification

The full text of the bounce will be delivered to the script,
with the envelope recipient as an argument.

-- Noel Jones