Sorry to bring this one up again, but I'm finding the various opinions on this question around the net to be really confusing. So...
I need to be able to send out newsletters to between 1000 and 5000 people. Each newsletter will have some degree of database-driven customization. I'm doing this on RedHat 9 with PHP 4.3.2, MySQL, and sendmail 8.12.10. My options would seem to be:
(1) The simple approach: Write a loop that calls PHP's mail() function for each customized message. There's a risk that, for a large number of messages, the PHP page's process may time out, so calling set_time_limit(0) somewhere in the script would be wise. This seems like the most straightforward way to do it, but people have alluded to performance problems, especially if PHP has to wait on sendmail to send out each message. It would be better if mail() just dropped the message into a sendmail queue and left it to sendmail to deliver the messages when it gets around to it. Some people have claimed that this is how sendmail works; others say that the PHP init string that invokes sendmail can be set to make it behave this way. A cron script might then be needed to poke sendmail every so often to handle its queue. Since I already have some code working that uses mail(), I'd prefer to stay with this approach if possible, but I'm sensitive to the performance issues.
(2) Use another PHP package like phpmailer to send the messages directly to my SMTP server. I can see this making sense, but what I don't know is whether phpmailer would just queue the messages and return immediately, or if it would wait around until the message was delivered.
(3) Build the page that delivers the messages so that it sends out a block of messages, perhaps just with mail, and then re-cycles itself to send another block, and so on. Seems a little kludgy to me -- admittedly, a matter of taste -- but I understand the rationale.
(4) Build the page so that it hands off the job of customizing and delivering the messages to a Perl script running alongside the PHP process. Seems reasonable, but I'd prefer to have all the code in one place.
Any advice? Again, I'd prefer to stay with a variant of #1, but am willing to be convinced otherwise. Any suggestions or clarifications of my ignorance would be appreciated.
Thanks,
Jim