php code for future mail sending

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Godfray
Forum Newbie
Posts: 3
Joined: Fri Jan 01, 2010 4:33 am

php code for future mail sending

Post 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.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Re: php code for future mail sending

Post 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.
Godfray
Forum Newbie
Posts: 3
Joined: Fri Jan 01, 2010 4:33 am

Re: php code for future mail sending

Post 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
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Re: php code for future mail sending

Post 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. =)
Post Reply