开发者

Send mail every n days

开发者 https://www.devze.com 2022-12-28 15:12 出处:网络
I have a php script that i use to send mail to customers. How can i execute this script e开发者_如何学编程very 5 days for example? Can anyone give me an idea or some links?

I have a php script that i use to send mail to customers. How can i execute this script e开发者_如何学编程very 5 days for example? Can anyone give me an idea or some links? Thanks


If you have a database underneath, you could store the date of the last mail in the database. The script then checks, what the last date in your database is. If this is more than n days in the past it sends a new mail and overwrites the date in the database with the current date.

Alternatively you could simply use Cron-jobs.


Use cron. Your cronjob file would look roughly like this:

* * */5 * * /usr/local/bin/php -q /www/scripts/myscript.php

That's pretty much it. Easy as pie!


I'm sure there are a multitude of methods you can use, so I'll tell you how I do it: I use cron which is only available on unix-type servers.


You can use a cron job If your server has the capability.

http://en.wikipedia.org/wiki/Cron

Another option is to use an external service that triggers your script once every five days.


The best you'll be to create a cronjob.

If you are not able to use cron on your webserver, get one and fetch the page with an external tools.

You can also run a daemon which "sleep" 5 five days between each send.*


You need some sort of external 'trigger' event.

Most likely a cron job to execute the task directly every n days, but since it looks like it may be web based you could also have a cron job (or windows task) that visits a predefined web page every n days, and have the web page send the email.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号