Incoming/Bounced email handling?

Hi all, got a question thats a little bit out of the ordinary.

I’ve been writing a contacts database in yii, part of the functionality is sending emails - These are either individually to a specific contact or to a group of contacts based on user-selected criteria.

This part is working out fairly nicely thanks to mail extension wrapping swiftmailer.

Now i’m up to the hard part - how to handle bounced emails.

What i’m after is something that can process bounced emails and give me the originating from address if it’s a permanent hard bounce - I then plan to pipe them into a yii console command to update the relevant contacts in the database. seems like what i’m after, but isn’t open source.

Anyone come across anything similar? It seems like a problem that has a lot of “edge” cases as there are a lot of mailers out there that don’t return anything like a standard bounce message.

For anyone that comes across this in the future:

PHPMailer-BMH is similar to what i’m after - however even with this there are a lot of emails that it can’t parse.

There is also a modified version available that adds the ability to parse based on a custom mail header which is useful so that you can track down exactly which message the bounce is for.

Well, I’m downloading now PHPMailer-BMH. Meanwhile if someone needs something else, I’ve written a small wiki for Catching bounce messages (NDR) and piping them to a Yii command

Edit: PHPMailer-BMH seems (is) much more advanced that what I present in the wiki. But who knows, maybe it’ll help someone, so I’m leaving this post.

Also, there’s an implementation by Jacmoe’s in his Bugitor project (see this thread) under protected/FetchEmailCommand.php, which uses a library called MIME E-mail message parser (mime_parser) by Manuel Lemos. As Bugitor project seems down as far as I’m editing this post, you can find another implementation here: PHP: Parse emails with email piping, Part 1 and Part 2