Hello, on 03/05/2009 08:20 PM Brian Hansen said the following: > 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. This is a totally wrong misconception. Using SMTP is the slowest method to queue messages. The misconception comes from the fact that sendmail is used in many servers and by default sendmail attempts to send the message right away when you queue it with the mail function. However sendmail has options to just drop the message in the local queue the message instead of deliverying it immediately. SMTP queueing is much slower because it uses a TCP (SMTP) connection to connect to the local server and drop the message queue, while when you use the regular mail function it just drops the message in the queue without TCP overhead. Your tests demonstrated that mail() outperforms SMTP because either you are not using sendmail or it is sendmail with the imediate delivery option disabled. You may want to take a look at the slides of a presentation that addressed this issue here. If you jump to slide 13 you can see a diagram that shows the path of the messages when you send them via different methods. As you may notice using SMTP is the long way to make the message reach the local mail server queue. http://www.phpclasses.org/browse/video/3/package/9.html > I have gotten the best results using PHP mail(). When the volume is belove > 6000 PHP mail() is by far the fastest. > > Would someone mind sharing experience and perhaps shedding some light on > this issue? > > 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)? The fastest way is to just drop the messages in the pickup folder that some mail servers offer. I am not sure which Linux/Unix servers support that, maybe postfix does, but I am sure Microsoft Exchange supports it. Anyway, if you use the regular mail function it may be fine too. Personally I use qmail but I can control the mail server I have in the machine of my sites, and just call qmail-inject program directly instead of the regular sendmail wrapper that the mail function calls. Other than that, queueing the messages is just one step of bulk message delivery. Often you need to compose and send complex messages that have characters then need to be encoded, maybe attachments, embeded pictures in HTML, etc.. That adds quite a bit of overhead to PHP script message delivery. I use the MIME message class below that the presentation above refers. It provides a bag of tricks to optimize bulk deliveries, depending on whether you need to personalize or not for each recipient. The talk about the slides above also address those issues and how they can be solved to maximize delivery performance and reliability with that class: http://www.phpclasses.org/mimemessage -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php