my program allows users to leave reminders to themselves.
tblReminder looks like this-
title
content
date

now the idea behind it is that once the date that the user chose comes, the user will recieve an email to his email account with the content of the reminder.

I can write a function that sends emails, but what I don't know is how to make the email to be sent (or in other words- to run the function) at a specific day without any action from the user.

I'm used to using links and buttons so I can't understand how to make something work without clicking anything or even opening the page!! help!

Dani AI

Generated

described a reminder table (title, content, date) and asked how to have emails sent automatically. pointed toward scheduled tasks and added resources. A practical, reliable solution is a server-side scheduled job that runs a PHP script, selects reminders whose date/time has arrived, sends the emails, and marks each row as sent so duplicates are avoided.

Implementation notes: add a sent flag (or sent_at timestamp) and an email or user_id field if not present. The script should run from the command line (or be triggered by an authenticated HTTP call), use prepared statements, and wrap send+mark operations in a transaction or use an atomic UPDATE to avoid race conditions. Prefer a proper SMTP library over mail() for deliverability; see PHPMailer and the PHP mail docs at php.net. Log successes and failures and implement a retry limit and backoff for transient errors.

Scheduling options depend on hosting access: on Unix-like hosts use cron (cron schedule helpers at crontab.guru), on Windows use Task Scheduler (docs at Microsoft), and if no server-side scheduler is available use an external cron service (for example, cron-job.org) to hit an authenticated endpoint. Example cron entry:

# run every hour
0 * * * * /usr/bin/php /path/to/send_reminders.php >> /var/log/send_reminders.log 2>&1

Final cautions: handle timezones (store UTC, convert when comparing), ensure the trigger endpoint is protected if used, monitor logs to detect duplicate sends, and set up SPF/DKIM or a reputable SMTP provider if deliverability is important. This covers the workflow that follows the suggestions from and the links shared by while adding concrete safety and deliverability tips.

Recommended Answers

All 2 Replies

my program allows users to leave reminders to themselves.
tblReminder looks like this-
title
content
date

now the idea behind it is that once the date that the user chose comes, the user will recieve an email to his email account with the content of the reminder.

I can write a function that sends emails, but what I don't know is how to make the email to be sent (or in other words- to run the function) at a specific day without any action from the user.

I'm used to using links and buttons so I can't understand how to make something work without clicking anything or even opening the page!! help!

For this you have to use CRONJOB, Googling with keyword 'CRONJOB PHP'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.