I have been using the sendmail function in PHP with Exim 4 so far when I had to send my mailing lists, I would like to know if there is a clean solution for that.
I'm quite sure that Facebook isn't sending email notifications in foreach loops.
I have tried to send them one by one using a Bash script doing a loop, but it's slow, and it's using database ressources.
I found a few mailing list managers on the Internet, I think it would be the best way to trac emails like
- Phplist or
- OemPro which isn't free but seems good
How to do this with the Zend framework? (Ref: "What's the best approach to sending email to hundreds of recipients from a Zend Framework application?")
For these kinds of mail loads you really have three options, and only one of them makes sense:
1) write your own application. For mailing lists that I've managed (optin marketing lists and newsletters for ecommerce sites and loyalty programs), I've handled loads of 200K - 1M emails using the perl Mail::Bulkmail package as the core of a relatively simple app.
2) Use a mailing list manager like listserv or mailman to handle the email and the unsubscribes. This works well if you can learn the package thoroughly.
3) Use a service that handles it for you. Lyris is good, campaignmail, etc- there are many reputable providers.
Frankly, you want to use an outside service. Negotiating mail whitelist status with the major providers is an ENORMOUS pain in the ass. These services have done it for you, and there's enough competition that the prices are pretty damn reasonable if you shop around. In addition, they'll prevent the marketing jackasses at your company from sending spam- the reputable providers are very strict about the email sources, as they don't want to risk getting blacklisted as spammers.
You can tell php to foreach over the list and not timeout by changing the timeout for the particular script. Another alternative, would be to create aliases that send to the whole shooting match at once.
However, you should be either using a "real" management tool like mailman, or outsourcing this, in my opinion.
Bear in mind that the technical aspects aren't the only thing to deal with in large mailing lists. If you're sending out large quantities of email that people will perceive as spam, you'll get complaints, and maybe blacklisted. (That's one reason botnets are popular among spammers nowadays - no one node will be obviously spamming.)
I'd suggest finding a reputable emailing service, because frankly it looks to me like you need more help with this than you're going to get online.
Personally, just as a PHP-level solution, I used PEAR Mail::Queue. This way I can process bulk email as needed. I run a site where a single user action can spawn hundreds of email notifications and would create noticeable lag to send them at creation time. A cron job sends them as needed, scaling to fit demand within limits. It works well for my needs, perhaps it can work for yours. :)