Automatically remove bounced email addresses from database?

Go To StackoverFlow.com

1

We have a big list of email addresses in our database from where people have signed up for newsletters for one of our websites.

We have a cron job that uses PHP to grab email address from the database and sends out the newsletters.

When an email gets bounced back, the cron job admin gets an email about it.

If we wanted a script to automatically remove bounced email address from the database, what is the best way to accomplish it? Is there someway to log bounced emails and then have a script parse the log and then remove the bad email addresses? Or is there a way to test for bounced email addresses via PHP?

2012-04-05 20:05
by Jake Wilson
What operating system and what web server is this running on? I'm assuming its linux/apache, but you might wish to include those tags since this question involves some webserver / cron sysadmin knowhow and not just email/php - NoName 2012-04-05 20:07
PHP can access IMAP and POP3 mail boxes, but testing for bounce messages is rather unreliable. The bounce can come from anywhere, and their format/content are wildly different each time - Marc B 2012-04-05 20:07


2

What you want to do is choose a "universal" bounce email address (say, bounce@example.com). You want to set your header "Return-Path" to "bounce@example.com".

Then, you have an external process check the "bounce@example.com" inbox for messages. Don't use this email account for anything else but bounces.

You will receive bounces, vacation messages, and other types of emails to this inbox. You just need to train your parser to look for certain patterns in the email. Your list of patterns won't be comprehensive at first, but you need to manually look at this inbox from time-to-time so you can further train your parser.

Your parser can be simple and look for simple substrings or even regular expressions. In most cases, regular expressions aren't necessary.

2012-04-05 21:07
by Wil Moore III


0

What you need is bounce parser.

You can receive bounce emails over POP3 or IMAP or even read from files (if you can configure your own MTA). Bounce emails will be delivered to email address specified in "Return-Path" header.

There is no good open-source bounce parser for PHP as i known. You can write your own. You can start from discovering parser from mailman (written in python).

2012-04-05 21:26
by puzzzo
Ads