views:

22

answers:

1

I'm trying to figure out a good solution for sending email notifications based on user preference. Users can set up notifications to come

  • Everytime the event occurs
  • Once an hour
  • Once a day
  • Once a week

Would the best way to do this be to set up a crontab that runs a .php every minute checking to see if anything needs to be sent out? Is there another way/more efficient way to schedule something like this?

+2  A: 

I'd say the following:

  • In case the email should be sent everytime the event occurs, then you don't need any crontab. Just send the email when the event occur.
  • Run a crontab once an hour. This crontab will fetch all events from the last hour, and send an email with all these events to the users requesting a hourly email.
  • Do the same once a day and once a week for users with daily and weekly emails preferences.
Vivien Barousse