1

I have a cron which generates the whole mail info and puts in a database table using $mail_queue->put(.....) with an option to delete emails after they're sent.

Here's where I need a little help: What is the best way to send the emails after I have the above info? Running the $mail_queue->sendMailsInQueue() right away, using other cron job(s) or something else?

The server limit by the way is 100 emails / minute. Currently the last csv diff for Mail_Queue is not applied (currently working with the support on that), so I can't use the "delay" option.

I had an idea to use the $seconds_to_send option, but it's calculated on the base of create_time field, which isn't a big help, but it's also an option.

Any ideas and suggestions would be really appreciated.

Till
  • 22,236
  • 4
  • 59
  • 89
RRStoyanov
  • 1,162
  • 1
  • 13
  • 23
  • 2
    @Kokos: there are plenty of legitimate reasons for bulk email. If he's writing a new email system from the ground up, rather than using one of the many, readily available systems spammers already use, I would bet good money that it serves a reasonable business purpose. – Eric J. Aug 14 '09 at 00:58
  • No - we need this system to better handle custom newsletters, alerts and registration emails – RRStoyanov Aug 14 '09 at 08:26
  • 3
    I just want to say that not everyone has the mission of spamming people. I myself am also working on something like this, and it's annoying what negative remarks you get the moment you use the words "mass" and "mail" in one sentece. Not everyone is trying to spam the world. – rockstardev Sep 22 '09 at 21:18

3 Answers3

3

Personally, I would go the cron way because it gives less opportunity for failure. Say your mail server stops responding or for some other reason becomes unavailable. Or what if your entire network goes offline for a few hours, but the servers are still generating emails. I say use the queue.

As for the delay thing, just have a service/cronjob pick up the queue every sixty seconds, pop 100 emails and send them, then quit. You might get a queue of emails to be sent but that's going to happen no matter what system you choose. The queue will empty during off-peak hours, anyways.

Tyler Menezes
  • 633
  • 1
  • 4
  • 17
  • Yes, a queue is good, but if your entire network comes offline for a few hours, and you're still pushing e-mails to the queue, your mailserver will be in trouble (100/min is okay, but that's sloooooow for any sort of *mass* mailing - 50K e-mails would take half a day). Yes, disk space is cheap - a similar incident has taught us that 300 GB of free space is just not enough. In other words, if you're in a hole, stop digging! You're the one sending the mails, it's not like they're going anywhere while you're offline. – Piskvor left the building Oct 11 '10 at 12:55
2

use two scripts. one for populating your mail_queue table with the emails you need to send and the second script to send those emails in chunks of 90 mails at a go. set the second script to be activated about every 2 minutes or so.

you could also just upgrade your hosting plan ;-)

kguest
  • 3,804
  • 3
  • 29
  • 31
0

why you dont loop through 100 emails and sleep for 60seconds. this costs you no servertime, the only downside your script runs a little longer.

Rufinus
  • 29,200
  • 6
  • 68
  • 84