문제

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?

도움이 되었습니까?

해결책

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.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top