|
Posted by Jamie Alessio on 10/01/19 11:08
> 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@YourDomain.com
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@example.com" bounced. You would presumably have some
record of sending a message to joe@example.com with an ID of 28 so you
could then mark that email as 'bounced' in your database. Then you could
remove joe@example.com 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@YourDomain.com>
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
Navigation:
[Reply to this message]
|