How can I send an email reminder 1 or 2 days before the deadline in php

hello, everyone!
I am making an application where the user can log in and create To Do tasks with a deadline, so far I’ve done the most of the part of it , even an email confirmation function but I’ve stuck to the part where I should send an email to the user when the date comes like 1 or 2 days before or even 2 hours before. I’ve seen some tutorial regarding Cron Job but still idk how to make a function linking parts together. Any of you guys could help with an example or some tutorials I could look up to? thank you in advance.

I think what you’re looking for is Cron.

1 Like

First, write the PHP code to extract the users who require an email, based on the date. I’d probably do a test form to try out several different dates until you have it running. Presumably you’ve got a date column that says when the notification is required, so it’s a simple query to compare the current (or test) against the dates in your database table.

Once you have that all working, changing it to a cron job and scheduling it every so often will do the job. Obviously if you need it to be worrying about hours rather than days warning, it needs to run more often.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.