I want to be able 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.
Can I just form my own VERP sender (i.e. to send to [email protected], can I just set my From: address for that recipient "mysender+user-domain-com.mydomain.com") and expect it to work, or do I need to configure postfix to correctly parse the failed DSN somehow? My problem is receipt of the failure notice, not getting the message to deliver to valid recipients when I do this.
Maybe an example will help.
When I send email from [email protected], I receive bounce notices just fine.
When I send email from [email protected], I don't receive any bounce notices. (Although correctly addressed emails, e.g., to: [email protected] go through just fine.) Perl's Mail module has a Verp sub-module, does python have anything like 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 [email protected] should be delivered to [email protected] with the To address [email protected]. 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:
and define the filter here:
This will cause the InboundProcessor.py script to receive all inbound messages via pipe. If the To address contains a + followed some bounce key value you can associate with an address that is no longer valid, you can mark that address inactive in your database.