0

Question of method here.

Every time someone responds to a comment you leave in my application, I want to send an email to that person (if notifications is on)...

At the moment i have a simple html php mailer that goes through every user that wants an email notification and sends it off..

This is working great, however lets say 5000 people all want a notification from this comment and people are commenting once every minute... will this cause a problem with php passing the mail over to the mail server or should it be able to cope with a for loop.. sending to all of those users every 1 minute?

Am i missing out on a trick?

bpeterson76
  • 12,918
  • 5
  • 49
  • 82
Jimmyt1988
  • 20,466
  • 41
  • 133
  • 233
  • "will this cause a problem with php passing the mail over to the mail server" maybe and then again maybe-not. –  May 29 '12 at 21:10
  • This *will* cause a problem in the recipients' inboxes - are you sure that everyone wants to get deluged by 200 mails an hour? You'll be on your way to the spam bin just for the volume of your mailings. (Consider aggregating multiple messages into one e-mail during rush hours) – Piskvor left the building May 29 '12 at 21:16
  • the user defines if he gets notifications or not ;) – Jimmyt1988 May 29 '12 at 21:22

3 Answers3

2

Scalability is going to be a major issue. However, more pressing is to examine the hosting you have right now. Big shared services like GoDaddy and HostMonster will throttle you at a certain amount per hour, which is in their TOS. Review that before anything.

Perhaps you could write your script to do a digest, and "bank" messages to users if they have x amount of activity per hour, etc.

Finally, consider that Email is not an exact science and you won't be able to guarantee delivery in an exact time period or at all for that matter. To increase deliverability you'll have to monitor your server, not hit services too many times in a row (for instance, AOL barks if you send more than a handful to them per second) and have a good maturity with your respective domain/IP to increase "trust"

It can be done. My company's app sends out hundreds of thousands of emails per day between three servers. But it's by no means trivial, and has taken two engineers more than a year to get really stable.

bpeterson76
  • 12,918
  • 5
  • 49
  • 82
1

If you're planning to do a huge amount of e-mailing like this, you might want to consider using a third-party service such as Sendgrid or Postmark.

Alternatively, if everyone can get the same e-mail, then you could send a single e-mail and have the recipients as BCCs on that e-mail.

Sam Starling
  • 5,298
  • 3
  • 35
  • 52
  • Does this process faster? it still has to send the email regardless but with extra header information? – Jimmyt1988 May 29 '12 at 21:24
  • 1
    In my experience, no. I've tried several different services, and they actually throttle their servers much, much more than I throttled my own (to prevent servers from rejecting emails when you send large quantities quickly) In one case, an outside "SMTP relay" service took 3 days to send what would take our small, outdated server just a couple of hours....all to protect themselves from being called "spammers" So, beware the mass- solution. – bpeterson76 May 29 '12 at 21:36
  • Is there a way to contact these bigger companies (hotmail, google, yahoo) and stop them from blocking if your site is trusted. What would the costs be etc. Any friends or colleagues who know this information. This is crucial to the running of my application. – Jimmyt1988 May 29 '12 at 21:55
  • There's nothing we've found. My server has been bulk emailing without a single complaint for 5+ years, and we still get throttled from time to time, sometimes without rhyme or reason. Compared to the "big guys" you're just a blip on the radar of these email services...they won't even bother talking to you. AOL, for example, won't even bother to deliver your mail sometimes at all. – bpeterson76 May 29 '12 at 22:06
  • that is excellent advice. the last remark made me laugh. So the problem is having enough money tog et them to listen. Let's hope i can avoid the spam block because users will soon get pissed off at the email companies if they don't get notified that someone left a comment :) .. P.S i'll get blamed first. haha – Jimmyt1988 May 29 '12 at 22:41
  • One of the solutions we've been brewing for a while has been to get an army of small "slices" of cloud servers -- we prefer Linode, which is cheap at $19.99/month. We'd use each as an SMTP server, being fed from a centralized server that "round robins" the emails to ensure we're not bombarding any one service with thousands in a row from one IP. So, we crawl through the list handing out emails to each server, but if one server gets two *.msn addresses in a row, for example, we skip to the next or pause if we don't have any others to parse it to. In theory it could allow infinite scaling. – bpeterson76 May 30 '12 at 14:44
  • Most services have one form of throttling or another but it's a lot easier to use them than to try to setup your own solution. (Disclaimer, I work on the Postmark team) Postmark throttles messages on a per-day basis but we can increase that number as needed. Good luck! – JP Toto Jun 21 '12 at 12:46
0

There's a discution about mass mailing on this thread on stackoverflow, see Sending mass email using PHP

Community
  • 1
  • 1
Gilles Quénot
  • 173,512
  • 41
  • 224
  • 223
  • This too is very helpful. I am picking up on the fact someone said rolling out emails in segments rather than all at once. – Jimmyt1988 May 29 '12 at 21:26
  • Careful, though. There's a difference between "mass mailing" and transactional email. Your emails are transactional. They are individual one-offs tailored to the recipient. Services like Postmark or Sendgrid are good at this form of email sending. – JP Toto Jun 21 '12 at 12:48