Re: Sending out large amounts of email

From: Date: Fri, 06 Mar 2009 00:00:22 +0000
Subject: Re: Sending out large amounts of email
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-289425@lists.php.net to get a copy of this message
I have been running some tests with PHP mail() function, PHPMailer and PEAR:Mail using 6000 mails at once. Here's a sumarry of some of the results: PHP mail() send out 6000 mails in 1.75 seconds. PHPMailer using PHP mail() send out 6000 mails in 1.87 seconds. PHPMailer using SMTP send out 6000 mails in 12 seconds (Error without succes). PEAR:Mail using PHP mail() send out 6000 mails in > 20 seconds (Apache reached 100% during this time). Running several test on PHPMailer using SMTP failed completely with more than 1000 mails.
Probably if you tried to send > 1,000 in one smtp conversation. Postfix has a setting that will control this (as far as I remember anyway). You'll need to cycle the connection. - connect - send 100 - disconnect repeat.
Everywhere on the net I read that sending out mail using PHP mail() is slow and it is a bad idea and that using some mail class with SMTP directly would be much better. I have tested the run my tests with Postfix as the SMTP.
Depends on the situation. Sometimes using an smtp server is better. Some hosts only let you send 'x' emails an hour or even 'x' emails every 5 minutes so you have to pause between each email being sent so you don't flood their servers. If you're only using your server and your tests show php mail() works, then use it. PHPMailer comes in very handy when you have to do one or more of the following: - send multipart emails (html + text) - include attachments - embed html images in the content - possibly send to an smtp server All of that functionality is already built, works, tested etc - you don't need to do it all again.
I have gotten the best results using PHP mail(). When the volume is belove 6000 PHP mail() is by far the fastest.
What about 10,000?
What is the best solution in real life dealing with huge amounts of mail? PHP mail() vs. some class using SMTP or binary sendmail (or wrapper)?
mail() internally calls the wrapper, I doubt you'd see much of a difference there. -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.general (#289425) next »