I am going to do a basic form to email script, which is not a problem where you press send and the email goes. but what i want to do is i want to put additional fields in there for date and time and the email will go on that particular date/time. what is the best way to achieve this? so for example at tuesday 13:30 i would like this script to run to send the email send-mail.php?mail_id=4 and tuesday 13:45 send-mail.php?mail_id=5 where mail_id changes the mail recipients, content etc.
do i need to run another script every single minute to check in mysql if there is anything to be send? like select * from mails where datetime = NOW() and if yes do the script? i dont think it is very good option as mysql will run 24/7 .
what are you recommendations
You could have a cron job that runs every 15 minutes and runs a sql statement like:
select * from mails where datetime <= NOW() AND isSent = 0
This would send all emails that are less then or equal to the current time. Make sure you update the record so you know it has been sent.