Event based email reminder

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
abeall
Forum Commoner
Posts: 41
Joined: Sun Feb 04, 2007 11:53 pm

Event based email reminder

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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)
spadmore
Forum Newbie
Posts: 2
Joined: Fri Dec 14, 2007 10:05 am

Post 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
abeall
Forum Commoner
Posts: 41
Joined: Sun Feb 04, 2007 11:53 pm

Post 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?
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Post 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.
abeall
Forum Commoner
Posts: 41
Joined: Sun Feb 04, 2007 11:53 pm

Post 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!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

You generally do not configure cron jobs through PHP. This would require PHP to have permission that it shouldn't have ;)
User avatar
emmbec
Forum Contributor
Posts: 112
Joined: Thu Sep 21, 2006 12:19 pm
Location: Queretaro, Mexico

Re: Event based email reminder

Post by emmbec »

How can I do it if my server is a Windows server?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Event based email reminder

Post by Chris Corbyn »

Task Scheduler.
Post Reply