Event based email reminder
Moderator: General Moderators
Event based email reminder
How would I go about making a system that sends automatic event based email reminders? My situation is a weekly online meeting, and I want to automatically send out an email reminder to all registered emails an hour before the event starts.
I could make a PHP script which allows me to manually hit it an hour before the event and it sends out a message to all registered emails, but I can't wrap my mind around how to make it do that automatically based on time. Any ideas would be appreciated.
I could make a PHP script which allows me to manually hit it an hour before the event and it sends out a message to all registered emails, but I can't wrap my mind around how to make it do that automatically based on time. Any ideas would be appreciated.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Have you considered using a cron job to periodically check (lets say every hour) for emails to send out?
cron + Swiftmailer =
cron + Swiftmailer =
Yes, cron job looks what I need, thanks.
Now the question is, can I start cron jobs via a PHP script? In this way I would like to do something like this:
1) Master cron job runs every 24 hours, and calls PHP script eventSchedule.php
2) eventSchedule.php does a database lookup for all events that day, and schedules a one-time cron job for 15 minutes before each event which calls eventNow.php
3) eventNow.php checks the database to see what the current event is, and sends out the email reminders, then stops the cron-job (if that's necessary)
Is that possible? Or do I have to run the cron-job every 15 minutes and call eventNow.php directly at that interval?
Now the question is, can I start cron jobs via a PHP script? In this way I would like to do something like this:
1) Master cron job runs every 24 hours, and calls PHP script eventSchedule.php
2) eventSchedule.php does a database lookup for all events that day, and schedules a one-time cron job for 15 minutes before each event which calls eventNow.php
3) eventNow.php checks the database to see what the current event is, and sends out the email reminders, then stops the cron-job (if that's necessary)
Is that possible? Or do I have to run the cron-job every 15 minutes and call eventNow.php directly at that interval?
Why complicate things?
I would just set an interval and have the script check for tasks and send the appropriate emails.
Depending on expected load and complexity, I'd probably schedule it for per minute checks. That's assuming you want emails sent right on the 15 minute before mark and you want to allow alert times at any time, eg. 4:45.
Of course, its hard to reliably know how long emails will take to arrive outside of an intranet environment. If you're sending to hotmail or some such service, you might wind up with mails arriving 5 minutes late.
I would just set an interval and have the script check for tasks and send the appropriate emails.
Depending on expected load and complexity, I'd probably schedule it for per minute checks. That's assuming you want emails sent right on the 15 minute before mark and you want to allow alert times at any time, eg. 4:45.
Of course, its hard to reliably know how long emails will take to arrive outside of an intranet environment. If you're sending to hotmail or some such service, you might wind up with mails arriving 5 minutes late.
Well, assuming it was simple to control cron jobs from PHP, I wouldn't consider it being more complicated, rather done correctly and efficiently. However, based on my research, it doesn't look like it's an option.
So I guess running a cron job every minute or so sounds like my final answer. Thanks all!
So I guess running a cron job every minute or so sounds like my final answer. Thanks all!
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Event based email reminder
How can I do it if my server is a Windows server?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Event based email reminder
Task Scheduler.