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?")


  • 6
    Unless this 100,000+ people actually knowingly signed up for this email, the answer is DON'T. – Paul Tomblin Sep 24 '09 at 11:29
  • 3
    If you have mailinglists that big and do not know how to professionaly handle mail, you are not qualified to do so anyways. – Sniek NL Sep 24 '09 at 11:45
  • 3
    Easy, guys. I agree with Scott Lundberg on this, it's not necessarily spam related. THAT SAID: @mnml, you should DEFINITELY edit this question to make your intentions crystal clear. Otherwise those who aren't already would be inclined to hop onto the spam bandwagon as well. The fact that you've accepted an answer with legitimate options implies this is legit. – squillman Sep 24 '09 at 13:51
  • 3
    @mnml: No, it's just that you're treading in dangerous water on that topic and the wording of the question can be interpreted in a good way or in a not-so-good way. If you add some wording to mention what it is that you're trying to accomplish, that ambiguity could be eliminated. Explain that you have a legitimate business need to send out mass mailing. – squillman Sep 24 '09 at 14:19
  • 4
    I don't see a problem with the question, either. Bulk e-mail is not always spam. – Ed Leighton-Dick Sep 24 '09 at 17:00

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.

  • You don't get blacklisted if you don't abuse and if you use SenderID and SPF records. – mnml Sep 24 '09 at 15:36
  • Actually, you can get blacklisted by the big players (yahoo, gmail, etc) if a certain number of folks report you as spam to their ISP and you aren't whitelisted. Unfortunately, with most newsletters, lots of folks forget they subscribed and simply hit the "mark as spam" button- leading to you getting misclassified. – Tim Howland Sep 24 '09 at 16:15
  • I don't think you get completely blacklisted when you are reported as spam on gmail. It's just blacklisting the mail reported as spam, not the sender. – mnml Sep 25 '09 at 9:53
  • Unfortunately, in the case of AOL, you're dead wrong. My direct personal experience as well as conversations with their postmasters when I was setting up whitelisting contradict you. – Tim Howland Sep 25 '09 at 12:41
  • 1
    Oh, and sometimes they'll blacklist just because they test your mail server and see that it may be a relay, according to their tests. Had that happen in the past as well. – Bart Silverstrim Sep 26 '09 at 11:59

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. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.