Asmaa E.
Asmaa E.

Reputation: 43

Send email one hour after a PHP script is run using Windows Task Scheduler

When a user adds a video to my website, I'd like to send an email one hour after their post, alerting them that it has been uploaded and is ready for their review.

Anyway to do this using Windows Task Scheduler? The email is sent using a php file, so ideally the php file would run and then an hour after it runs is when the email is sent.

Upvotes: 1

Views: 944

Answers (1)

raidenace
raidenace

Reputation: 12834

Some assumptions:

  • You have stored the file upload date/time in database somewhere.
  • You have a PHP script that is written to read this database field and check if its been an hour since the upload.
  • You also have a field which flag if the email has been sent for an upload.

Assuming the above three are true you can have a Task Scheduler entry like

C:\Path\to\php.exe -f "C:\Path\to\send_email.php"

If you are using older versions of Windows which does not allow you to enter commands in it but only select a program, then save this command as a batch file and select it from the interface

Now bear in mind if you want it to send emails after exact one hour then you will need to schedule this task to run every minute.

Upvotes: 1

Related Questions