MBF Knowledge Base

I want to send emails in Python so that I can parse bounces. VERP seems to be the solution to this. However, I don't receive the bounce notification when I set my from address (not the MIMEMultipart object's "From" value) to include the VERP delimiter. How do I accomplish this?

You should use "Return-Path" not FROM as the address to which a bounced message is sent. Specifying the return path in an outbound message using Postfix doesn't require special configuration.

The configuration requirement for Postfix to handle variable inbound messages can be handled with the + in an address because the + and everything that follows are usually ignored. So setting Return-Path to joe+bounce@here.com should be delivered to joe@here.com with the To address joe+bounce@here.com. Programmatic handling of the message could be done with the addition of a filter to the master.cf file.

Put this in the service list:

smtp      inet  n       -       -       -       -       smtpd
  -o content_filter=filter:dummy

and define the filter here:

filter    unix  -       n       n       -      10       pipe
flags=Rq user=filter null_sender=
argv=/home/filter/InboundProcessor.py -f ${sender} -- ${recipient}

This will cause the InboundProcessor.py script to receive all inbound messages via pipe. If the To address contains a + followed by some bounce key value you can associate with an address that is no longer valid, you can mark that address inactive in your database.