I want to send mail to user daily. For that I will store the database some records. The PHP Script will send each record daily as mail to开发者_开发问答 the user. These should be done automatically without admin or user interaction. Please give me some help or suggestion
PHP can be run from the command line like any shell script, Perl script or so on. See Using PHP from the command line.
For the daily job put such a command line in your cron. See Schedule tasks on Linux using crontab.
add this to crontab
php -q /path/to/yourscript.php
There are basically two ways to accomplish this.
The first is to configure at the operating system level to run the script at the appropriate times (e.g. cron or Windows Task Scheduler). The other option is to use a script like phpJobScheduler will will run jobs by inserting a check in your other scripts. The important thing is that you need a reasonable amount of traffic on your web server so that the check is invoked often enough.
You could also use a webcron service to trigger your script. If you are not hosting your website on a dedicated box, you might not be able to configure crontabs.
精彩评论