Re: Handling email bouncebacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jamie,

Thanks for your detailed response and suggestions. Here is where I am at currently:

I have set up a bounce@xxxxxxx address and POP3 account on my server to handle all bounces. When my system sends out the email campaign and loops through the addresses, I encode the recipient address and then at it to the return path like so: Return-Path: encodedaddress <bounce@xxxxxxx>

Then I have a function using the IMAP functions in PHP that opens the mailbox and reads the following information:
imap_header, imap_body


The header has the To: address containing the actual pop account address prepended by the encoded recipient address. I decode the address, and now I have the intended recipient.

The body has the complete body of the email. From my research I know(think) that I am looking for a "Status: x.x.x" value in the body. I explode the body into an array and then use an in_array condition to look for status codes.

So far I am successful at getting the intended recipient address and the status code. Now I have to do something with that info :)

Thanks again for your time.

Chris

On Feb 16, 2005, at 1:31 PM, Jamie Alessio wrote:

I am looking for a way to manage email bouncebacks on my Linux server for one of my client's email marketing system. What I would like to do is have a way of capturing the email address from the header of each bounce and insert it into a MySQL table. At that point I can do the requisite scrubbing of the lists. I believe that I saw a PHP class a while back that handled this. Does anyone have any experience with this?
Chris,
I find that the tricky part of this sort of thing is actually accessing the bounce messages. I prefer to process the messages as they arrive at the mail server which means getting your MTA to hand off the entire message to your script for processing. My solution is to use qmail (www.qmail.org) as my MTA and have qmail pipe the messages that are delivered to certain address to my script. At that point you can then parse through the message and take appropriate action. Other MTAs like sendmail can do this too, but what qmail offers is the ability to easily handle incoming addresses that look like this:


bounce-28-joe=example.com@xxxxxxxxxxxxxx

So, you direct bounce-*@yourdomain.com to a script (a command line PHP script in this case) and you can easily ascertain that your message with the ID=28 to "joe@xxxxxxxxxxx" bounced. You would presumably have some record of sending a message to joe@xxxxxxxxxxx with an ID of 28 so you could then mark that email as 'bounced' in your database. Then you could remove joe@xxxxxxxxxxx from the list when you have record of the address bounces something like three consecutive times. To get bounce messages in the above format you need to add a header like this to your outgoing email:

Return-Path: <bounce-28-joe=example.com@xxxxxxxxxxxxxx>

This is all very qmail-ish and is completely ripped off from ezmlm (www.ezmlm.org) which is a qmail-based mailing list manager written by the author of qmail. If you need to do bounce handling on a large scale with a lot of different lists I suggest researching how ezmlm handles it.

Another poster, Ligaya, mentioned what is probably a simpler solution if you need to do this on a small scale. Get your MTA to deliver the bounce messages to a single mailbox and then use PHP's IMAP functions to get the mail and parse it or you may even be able to access the mbox file directly using PEAR's Mail_Mbox class (http://pear.php.net/package/Mail_Mbox).

Hope that helps - just wanted to throw out the more complex scenario as you might not have initially thought of an approach like that.

- Jamie



--

Chris Bruce
chris@xxxxxxxxxxxx

Idextrus E-Business Architects
http://www.idextrus.com
3282 Wilmar Cres.
Mississauga, ON
L5L4B2
CA
905.828.9189 South Office
705.361.0331 North Office

****************************************************************
This e-mail and its contents are privileged, confidential and
subject to copyright.  If you are not the intended recipient,
please delete this e-mail immediately.  Any unauthorized use
or disclosure of the information herein is prohibited.


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux