Rumesh
Rumesh

Reputation: 339

PHP triggering mail functions at a set time and date

I want to check the stock level every day at a certain time (say 11pm GMT) and email a list of items that are low on stock to the admin. I have managed to get the mailing function working but I am struggling to limit the checks to once a day (right now it sends an email to the admin email every time the page loads)

Your help will be much appreciated!

Upvotes: 2

Views: 640

Answers (2)

Slava Rozhnev
Slava Rozhnev

Reputation: 10163

In case that impossible to run a cron job, you can save last mail time in DB or file and check timeout on page load.

Upvotes: 1

Fabio
Fabio

Reputation: 23480

I think that you just need to put your script in a separate file and run once per day with a cron job

You might want to read more about cron jobs in this post How to create cron job using PHP?

Upvotes: 2

Related Questions