Opinion on sending emails from php Opinion on sending emails from php codeigniter codeigniter

Opinion on sending emails from php


Use a PHP mailer class such as PHPmailer or SwiftMailer, you can send mails directly trough SMTP that way, which will be much faster.And yes sending large quantities of emails is best done via cron so you send X emails every minute. You will avoid server overload that way.If you can't create cron jobs on your server I suggest you switch your hosting provider, otherwise the website you linked is your only viable alternative (but you are depending on some third party this way, which isn't really cool)


If you can't use a periodic job, you might want to look into a queuing solution like Gearman.

What you would want to do is push all of your emails into the queue and have 1 or more long-running workers that pick jobs off the queue. If you want to add delay into the system, just add a sleep in there as well.

Some really basic pseudocode:

#wherever you launch the jobs fromfor each user  gearman.push(user.generateEmail())#in your consumer scriptwhile true  message = gearman.consume()  message.send()  sleep(5)