> From: J J <[EMAIL PROTECTED]>
> 
> What do you use for mass newsletter mailing say for
> 5000+ members every month?  At the same time, I'd like
> to be able to track who opened the message, any links
> they clicked inside the message, bounced messages,
> etc.
> 
> I keep seeing reports that PHP/mail have trouble
> sending more than a few hundred messages depending on
> the machine.   But for mass mailings you get into
> majordomo, etc, which seems to bulky for my needs.
> 
> Any thoughts or suggestions on possible solutions?
> Thank you in advance!

This general question is asked often, and I found lots of good information
by searching the list archives. So check the archives, read the manual, read
whatever articles you can find. (Check zend.com and sitepoint.com.) This
will give you all the info you need to successfully send to a small list --
verify you can do that. Assuming you've got that down, here's a quick
description of the system I built on a commercial Linux host using a MySQL
database:

- It takes several minutes to send hundreds of emails, so it's best done in
the background. You'll need PHP available to run as a CGI/CLI called from a
cron tab.

- My solution is part of a content management system. Site administrators
create the body of the email from database info. When a user hits the send
button, the email is saved to a MySQL table which has fields for Time (time
created), ListSize (number of addresses), Invalids (bad address formats),
Attempts, and InProgress (an enum field used as a flag). There are lots more
fields for storing parts of the message, etc., but that's not important to
the approach. There's also a database table for storing the email address
list, with fields for Time (same as the message table), Valid (valid
format), Failed, Attempted, and TimeAttempted.

- The cron tab calls a PHP script every five minutes which queries the
database message table for fields where ListSize-Invalids > Attempts and
InProgress = "N". If the result set is less than 1, the script exits.
Otherwise, it sets the InProgress flay to "Y" and selects 50 email addresses
from the addresses table where Attempted = "N" and Valid = "Y" and Time
matches Time from the message table.

- The sending PHP script then loops through the 50 addresses, and each time
through the loop updates the address table for the address being processed,
setting Attempted to "Y", Failed to "Y" or "N", and TimeAttempted to a
timestamp value. After finishing the 50-address loop, the script updates the
message table to set Attempts to a greater value and InProgress to "N".

- Finally, the sending script selects all "completed" messages (where
ListSize-Invalids = Attempts and InProgress = "N"), orders the selection by
Time descending, and deletes all but the most recent, and also deletes the
Time-matching email addresses from the address table. This means that only
active info and the last-completed mailing info is kept in the database.

- Another nice thing about running the sending script as a CLI is that when
a PHP script running as a module sends email, the return-path in the email
header is listed as something like "[EMAIL PROTECTED]" and bounced email
isn't accessible. (This is true on the commercial host I'm using, anyway.)
But when the PHP script runs as a CGI, the return-path can be set to the
user and the bounces are accessible.

- Using the info stored in the message table and address table, I can
produce a report on a mailing attempt. I also built a pop up window that
refreshes every few minutes so I can monitor the progress of sending to a
large list.

There are lots of other details, of course, but it took too long to describe
the general approach -- whew! Anyway, for anyone struggling with this sort
of thing, building a queuing system like this seems to work well, and I'm
sure it would be safe to greatly increase the speed above 50/5 minutes.

HTH

--
Lowell Allen


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to