Page 1 of 1
php code for future mail sending
Posted: Mon Jan 04, 2010 4:49 am
by Godfray
I am developing a greeting card website with PHP. At this point in time I am able to send card for current date and time (today’s date - immediately), but I need to know if I need to send card on some other future dates/ time, what should be done, give your suggestions please. If anyone has sample source code for this, please provide me.
Re: php code for future mail sending
Posted: Mon Jan 04, 2010 7:32 am
by jason
Simply store the needed information to send the card in a database, allowing with the date of when to send the card. You then have a simple little cron job that runs once a day, grabs all the cards that should be send out that day that haven't been sent yet, and send them out as normal.
Re: php code for future mail sending
Posted: Tue Jan 05, 2010 7:43 am
by Godfray
Thanks for your suggestion Jason. Can you please provide me any tutorial for cron job, the reason why i ask you is I am not aware about cron job. Just tell me few tips how to integrate this in the website.
Thanks
Re: php code for future mail sending
Posted: Tue Jan 05, 2010 8:18 am
by jason
Honestly, this is the first thing I did to answer your question:
http://www.google.ca/search?q=PHP+scripts+as+cron+jobs
It presents numerous tutorials that I think cover the topic fairly well. I think this should get you started. Most hosting services provide a way to easily create cron jobs, so it might even be easier for you then the tutorials describe (not that cron is hard).
The actual logic of the script (querying the database, getting the emails for the date, etc) is something I assume you can handle. Of course, we are always here to help. =)