Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending php emails at certain intervals

Status
Not open for further replies.

electricphp

Programmer
Feb 20, 2008
71
US
I Have a site that needs a function (email settings).

If a user selects daily, once a week, every other week, every three days, they are supposed to receive an email with listings from a mysql database.

I don't really know how to do this. I think this may be done with cron jobs, but I would rather do this with php. Any suggestions?
 
Yes this is done with cron jobs, or scheduled tasks depending on your OS.

It is done with PHP as its the one that sends the email, but the cron job or scheduled task is the one that makes the PHP script run.

With that said: you can set a cron job to run every day at a specific time, and then your PHP code checks what emails should be sent based on data from a table.

Basically you keep a table with how often an email should be sent, and the last time it was sent. The your query returns those whose last sent date is far enough in the past that it matches the interval set.





----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top