PHP mass emailing and handling bounces

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm putting together a mass mailing application for sending out newsletters
from a site admin area (no spam).

I'm wondering how I can automate the removal of bounced addresses in this
application. The ideal situation would be that returning mail triggers a
script that removes the address of said message's recipient from the list.

I'm thinking about a script that checks the pop3 server of the reply-to
address and parses the inbox to look for returned mail and removes those
addresses from my database. This script could be run periodically as a cron
job or everytime before sending out the next mailing.

Any other suggestions, ideas?


Re: PHP mass emailing and handling bounces

Quoted text here. Click to load it

*IF* you can arrange it, point your reply-to address to a mailbox
hosted on a server that supports .forward files or aliases that
pipe into a program.  (Linux or BSD host running Sendmail, Smail,
Exim, or similar).  Your program (which could be standalone PHP if
it's available) gets invoked with the bounce as standard input.  It
reads the headers, finds the coded info you stuck in the header to
indicate who you sent to, and uses it to flag and/or delete bouncing
addresses in your database.

There's no need for polling a pop3 box.  It takes no CPU time if
nothing bounces.  However, if you're doing this on a cheap hosted
web site, it's probably difficult to get this kind of access.

                    Gordon L. Burditt

Re: PHP mass emailing and handling bounces

Quoted text here. Click to load it

Thank you Gordon,

I was thinking about something like that, but you formulate it much better
than the vague concept I had in mind.

While I might be able to get that level of server access on my current
project I'd like to create something that is portable to less luxurious
environments as well for the sake of re-use.

What do you think of my other idea? Is it doable or am I overlooking
something major? I don't think that cpu time will be a issue. After all
there are quite a few web-based email systems written in php (SQWebmail,
Horde, ...) - I've never experienced any performance issues with those...


Re: PHP mass emailing and handling bounces


on 06/14/2005 10:28 AM somaboy mx said the following:
Quoted text here. Click to load it

Yes, I do that all the time and it works very well. I use this pop3
client class for that porpose:

Beware of solutions that hang on procmail, .qmail, etc.. because if your
script has a bug that makes it not process the messages imediately, you
may be choking or loosing your incoming e-mail. Polling a POP3 mailbox
is safer as you never loose messages.

What you need to do is not to set the Reply-To: header but the return
path address. Return path address is not set by an header. It depends on
the method you are using to send messages.

You may want to take a look at this class for composing and sending
messages correctly in a way that it prevents being confused with spam.

It can set the return path address correctly regardless the method you
use for delivery. It supports several different methods.

It also has a means to optimize deliveries for bulk mailing.  I use this
class to send almost 4 million messages a month from the same site. See
the SetBulkMail function and message body caching support:


Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP /

PHP Reviews - Reviews of PHP books and other products /

Metastorage - Data object relational mapping layer generator

Site Timeline