Page 1 of 1

Event based email reminder

Posted: Thu Dec 13, 2007 10:58 pm
by abeall
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.

Posted: Thu Dec 13, 2007 11:00 pm
by John Cartwright
Have you considered using a cron job to periodically check (lets say every hour) for emails to send out?

cron + Swiftmailer = 8)

Posted: Fri Dec 14, 2007 10:10 am
by spadmore
You could use cron to launch the script and update the cron tab when you schedule a new event. That will give you the most accurate alerts....


- Shelon Padmore

Posted: Fri Dec 14, 2007 6:32 pm
by abeall
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?

Posted: Sat Dec 15, 2007 1:29 am
by Stryks
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.

Posted: Sat Dec 15, 2007 4:49 pm
by abeall
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!

Posted: Sat Dec 15, 2007 5:22 pm
by John Cartwright
You generally do not configure cron jobs through PHP. This would require PHP to have permission that it shouldn't have ;)

Re: Event based email reminder

Posted: Mon Mar 03, 2008 4:06 pm
by emmbec
How can I do it if my server is a Windows server?

Re: Event based email reminder

Posted: Mon Mar 03, 2008 7:17 pm
by Chris Corbyn
Task Scheduler.