Detect bouncing messages from an IMAP folder and allow further processing
This software gives you a command line utility that can connect to an IMAP mailbox, detect the bouncing messages in that folder and then make a call to a webserver, informing that web application of the subscribers found to be bouncing.
When started, this command line will do the following:
For a list of all command line options, run the utility with the -h flag, like:
# bin/bounce_srv -h
The easiest would be to create a script that has the following content (this is EEA specific and needs to be tweaked with the proper parameters):
This script should be called from cron, at 6-12 hours interval.
The best bouncing detection is provided by using the VERP concepts, which involve specifying a special email address as the value for the Return-Path header, inside the sent emails. This command line utility then tries to parse those headers and extract the newsletter id and the subscriber's email from that header.
An example of a VERP email address is:
newsletter-id-no-reply-DESTINATION_MAILBOX=DESTINATION_DOMAIN@mail.europa.eu
You can notice the following information:
The command line utility will read custom filters from the web application. They will be checked against the "delivery status report" subpart from an email message. In theory, all these filters shouldn't be needed.
A good start for a set of filters is this: (taken from: http://blog.dazoot.ro/2009/09/procesare-bounce-uri-in-real-time/ )
# web.de user unknown # web.de unknown local part # gmx.de user is unknown # aol.com MAILBOX NOT FOUND # aim.com by AOL But, your recipient never logged onto their free AIM Mail account. # yahoo 554 delivery error: dd.*cannot be delivered.*disabled or discontinued.*yahoo 554 delivery error: dd This user doesn't have a.*yahoo # hotmail Requested action not taken: mailbox unavailable # freenet.de 550 unrouteable address # cabanova.com sorry, that mailbox isn't in my list of allowed mailboxes # att.net 551 not our customer # sbcglobal.net Addressee unknown # mail.ru user not found # mail.ru invalid mailbox # k.ro No such user. # k.ro DOESN'T EXIST # qmail no such mailbox # text No Such User # text No Such mailbox # easynet, text Unknown user # text Unknown mailbox # text Invalid recipient # text Recipient unknown # text, apropo.ro No such email # text No such mail # text unknown recipient # as.ro No such person at this address # text #5.1.0 Address rejected
re.compile("55d sorry, no mailbox", re.I), # text, qmail
# text invalid address # text User account is unavailable # text Recipient not found # text User account is unavailable # text does not exist # text No account by that name here # text Mailbox is inactive # text Nonexistent user # text no mailbox here by that name # text mail not found # text Mailbox disabled # text No such recipient # text - freemail.hu 5.1.1
- Change: cleaned up package of pylint violations [ichimdav #4140]
- First release, it can connect to IMAP server, detect bounces, make a call into Plone, move processed messages into backup folder