Hi All,
Is there any way to send email in php without user interaction.The scenario is some thing like this.. I want to send email's to persons based on his/her birthday.I need your help. Please help me to solve this...
Thanks :)
Hi All,
Is there any way to send email in php without user interaction.The scenario is some thing like this.. I want to send email's to persons based on his/her birthday.I need your help. Please help me to solve this...
Thanks :)
As suggested, the usual solution is a scheduled task that runs a PHP script daily (cron on Linux, Task Scheduler on Windows). A simple, reliable workflow: keep birthdays and a last_birthday_email_sent timestamp in the database; run a CLI PHP script once a day that selects today’s birthdays, sends mail via an SMTP-capable library, and updates last_birthday_email_sent to avoid duplicates.
Important implementation points:
Use an SMTP library (for example, PHPMailer) rather than relying on mail() for better deliverability and authentication (PHPMailer, PHP mail() docs: php.net).
Query for birthdays using month/day and check last_birthday_email_sent so each person gets one mail per year. Example SQL:
SELECT id, email
FROM users
WHERE MONTH(birthdate) = MONTH(CURDATE())
AND DAY(birthdate) = DAY(CURDATE())
AND (last_birthday_email_sent IS NULL OR YEAR(last_birthday_email_sent) < YEAR(CURDATE())); Send personalized multipart (text+HTML) mail, log successes/failures, and update last_birthday_email_sent only after successful delivery.
Schedule example (Linux cron): run the script at 09:00 daily.
0 9 * * * /usr/bin/php -f /var/www/scripts/send_birthday_emails.php >> /var/log/birthday_email.log 2>&1 Notes and troubleshooting:
For cron syntax and options see the crontab manual (crontab(5)).
Jump to Post— somedude3488 228you need to use a cron job. search google for it and I think you'll find your answer.
you need to use a cron job. search google for it and I think you'll find your answer.
Thanks..
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.