2008-03-24 11:52:25 +0000

If you are using a Ruby on Rails app, or Nitro, or just a plain Ruby application that handles email, you will need to handle at some point, bounced messages. This a simple way to get to the guts of the email and find out what the error codes are…

Here we go:

We need to get an email to handle, so something like:

mail = TMail::Mail.parse(message)

Then, we need to check if this is a bounced email or not, so:

mail.content_type == 'multipart/report'

This will return true or false, if it is true, we need to do more handling to find out the error codes etc.

So, first, find the part of the email that has the message/delivery-status section like this:

lindsaar.net is proudly bought to you by the letters l, i, n, d, s, a, r, e and t.
The comments on this site belong to Mikel Lindsaar and do not reflect the viewpoint of my employer, parents or anyone else.
Powered by Sinatra