Re: Is a while loop the most efficient way to send out multiple emails?
| From: | lists at lindensys dot net | Date: | Tue, 30 Dec 2003 13:35:47 +0000 |
| Subject: | Re: Is a while loop the most efficient way to send out multiple emails? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-173480@lists.php.net to get a copy of this message | ||
> I currently run a few newsletters that go out to small groups of
> % 50 to 100 people. I use a while loop to send out the emails. I chose
I have a module that does about about 100 emails (10Kb of data per email, which is a decent sized
email) in 8 - 10 seconds. (Does around 610 - 625 emails per minute). This is accomplished by
skipping PHP's internal mail functionality entirely and making a direct socket connection to
the SMTP server. Another benefit of this is that any MySQL delay can be removed from the actual mail
functionality by adding all the recipients to the class, and closing the MySQL query - before
sending the emails. Ultimately, the speed really depends on the SMTP server. I'm sure with a
little hacking, I may be able to get 650 - 675 emails per minute.
One faster method of sending bulk emails requires A) having direct access to the filesystem of
the mail server, and B) hacking sendmail configuration - which both mean "root" access.
I've gotten up to 850 emails per minute with this method.
The class is easy to use - basically:
$_Mailer = &new mod_sendmail();
$_Mail->setSubject( strText );
$_Mail->setBody( strText );
$_Mail->addRecipient( strName, strEmail );
$_log = $_Mail->sendAll();
The $_log var is an array in the format of:
$_log[ strEmail ] = strData
strEmail is the intended recipient, and and strData will either be A) the MsgID returned by the SMTP
server on success or B) a "0" if failed. This makes it possible to add a function to
re-send failed emails later.
If you want the socket-based code, just send me a private email to kode@kodekrash.com. I'm
working on getting a code repository going, but for now, just have to send it to you directly.
-- James
kode@kodekrash.com