This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I was wondering if there is any kind of standard way to identify a bounced email (ie after sending to an address that doesn't exist)?
I am using JavaMail to read the incoming email, so I have access to all of the data stored - but programatially I am unsure what is the best option to identify these bounced emails.
Do all bounced emails have the "from" set to "email@example.com"?
Do all bounced emails have the "subject" set to "Delivery Status Notification (Failure)"?
Does anyone know of any standard way to detect these errors?
Since I need to handle these bounces (by flagging them, so I don't keep emailing invalid addresses), I want to make sure that the script I write will catch all of the errors from different mail servers.
Unfortunately the answer to all of those questions is "No".
The script I have for capturing bounce messages has about a dozen different subject lines. And I haven't even attempted to extract the culprit e-mail address from the bounce message; the message formats vary even more widely than the subject lines do.
All you can do is to monitor the bounce messages as they come in, and modify your procedure to handle each different format as you encounter it.
However... there is a new e-mail feature called Delivery Status Notification. Here's a link to the part of the JavaMail API documentation which describes it: http://javamail.kenai.com/nonav/javadocs/com/sun/mail/dsn/package-summary.html. It comes with a Warning, and there's no guarantee that servers will send you these things, and so on and so on, but it might be worth experimenting with them.
Joined: Sep 30, 2009
I had a feeling that would be the answer
Just thought of an easy way I can do this on my system though...
Simply compare the "from" data in the incoming email, then cross reference this against the list of email addresses within the DB - if there is no match, it is safe to say that the email has bounced.
I can then forward all of the bounced emails content & headers to a certain email address, where I can begin looking at these on a case by case basis to see how I can extract the original "to" from the postmaster delivery failure.