The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Detect Bounced Emails


My client is developing an auto-mailer system in .NET and needs built-in bounced email detection. I'm having trouble finding out how we can handle the bounced email messages.

As I see it there are two ways of detecting bounced emails:

One is to append a reference (id or something) to the mail's subject and parse the subject if the mail is send back by the receiving server

The other is to add a 'return-path' header that has a message-bound email address (ie: as it's value and set up a mailbox to which those emails are routed (using a wildcard). If the receiving mail server cannot resolve the email address into a known username then it will send back a message to the email address specified in the 'return-path' header. A service would then check for messages in the mailbox, resolve the TO address and look up the recipient in our database in order to mark it as erroneous.

The problem with the first approach is that you need to find a way of getting the original message which is usually attached to the Non-Deliverable Receipt (NDR). Some mail servers even neglect to send the original message as an attachment.

The problem with the second approach is that our outgoing mail server overwrites the 'return-path' header with the value specified in the 'from' header.

Any thoughts on how to best implement this?

PS: sorry for the long post
Phil Gates
Wednesday, September 27, 2006
We do it the second way.  So if your smtp server is rewriting the headers, I'd fix that, or change smtp servers.
Marcus Tettmar Send private email
Wednesday, September 27, 2006
Here is another approach. Use a unique FROM address for each of your emails. It might be something like ""

The "dave-whatever" part would tie back to that specific email address, for that campaign. The key to this setup, is to make sure your mail server has a catch-all mailbox/account, which all bounces should then come back too (since the dynamically generated FROM address doesn't actually exist on the mail server).

Then, POP into that account, grab all the messages. If the "TO" address maps to a previously used "FROM" address you can tell which address bounced.

Also, be sure you set a Reply-To header, so human replies will go back to a real person.

<plug type=shameless>
If you need a more robust solution for parsing NDRs, check out

dave wanta
Wednesday, September 27, 2006
Dude, Where's My Car?
Wednesday, September 27, 2006

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz