Does anyone have any experience creating mail queues? I have a script that emails people everytime they sign up with a MIME email class (http://www.phpclasses.org/browse/package/9.html) but it can cause high server load when there is a bit of traffic... So I figure I can reduce some server load if I were able to create some kind of mail queue.... So if someone can point me into the right direction, that'll be great.
Thanks in advance.
The problem from the email class is this function (which takes a 1143ms to execute under some stress - the profiler shows strcmp and strlen being the longest to execute):
I've used that MIME Mail class, and I prefer PHPMailer over it, especially in reliance and speed. I've seen this mail class run on sites with hundreds of new sign ups a day, and never break under the load.
I'd also use the SMTP option with PHPMailer, as Apache + PHP wasn't really designed to send email, w/ the Mail function. Connecting directly the SMTP to send out email is much faster and takes a lot of the load off of PHP.
As far as the queue goes, you can do it several ways...
You could add it to a file, then a cron goes through and grabs like, the first 100 lines, sends out those emails every 5 mins or so.
Or, you can have it in a DB, and when you insert they sign up, insert them into your Database, then have the CRON run every like... 3 - 5 mins, or whatever delay you want, and it goes through the DB and finds all of the users that have signed up, but have yet to receive their E-mail.
The Following User Says Thank You to dschreck For This Useful Post: