NYCPHP Meetup

NYPHP.org

[nycphp-talk] building an 1-way email list manager

David Mintz dmintz at davidmintz.org
Mon Nov 14 22:38:19 EST 2005


On Mon, 14 Nov 2005, Jeff Loiselle wrote:

> I started building one of these bad boys a couple years ago. You are
> welcome to have a copy of my code and schema. I never finished the
> project, but it does send mail, track bounces, track how many people
> opened a message, and sends messages.  It even has a rudimentary SOAP
> interface for adding members to the list.

Deeply interesting! Wrap it up, I'll take it.

>
> In order for it to send the messages, you have to run a PHP script
> indefinitely in the background. I did this because you can't set the
> Reply-To from PHP which is crucial for bounce tracking.

Do you mean Return-path? I have discovered that it's tricky -- different
tricks work in different environments. I still need guru help (or some
more hours of hair-pulling). This has to work on a shared server where you
can't mess with php.ini, sendmail configuration, etc.

> Unfortunately
> I found out later that this could be done with mail() f parameter, but
> whatever. This actually uses PEAR:Mail to send all the mail via SMTP.

I am leaning towards PEAR::Mail with the sendmail backend (which can mean
qmail, e.g,. on my shared host). but I haven't ruled out phpmailer

> I'm sure it's slow as hell and completely the incorrect way to do it.
> But it worked for me at the time!

What did Larry Wall teach you about that? (Answer: A program is "correct"
if it runs once before your boss fires you."  Or something to that
effect.)

Running a daemon or some other really long-lived process is not an option.
I am thinking cron: every couple of hours, wake up and send. Do 50 or so
and sleep for a few seconds until you're done. Yeah that would take a long
time for 200,000 emails but this is never gonna need to scale like that.

I have looked at PEAR::Mail:Queue and I don't quite agree with (maybe
don't understand) its storage logic. Why save n copies of the selfsame
email message body in your database? I am actually thinking of saving (for
cron, for later) ONE copy of the message and ONE sql query. At send time,
the cron job will run the SQL against my database of people to fetch a
recipient list. If there's personalization, fine; the message body has
placeholders ("Dear {FIRSTNAME} {LASTNAME}...") that I str_replace() as I
iterate through the recipient list.



---
David Mintz
http://davidmintz.org/



More information about the talk mailing list