问题
I have a site where many user registered.There is some activities for each registered user I want to sent them a weekly stats email for their each week activity.
Each weekly mail have weekly stats for user registered
How I can sent them weekly mail without cron job.
Is it possible to send weekly dynamic mail using mail chaimp or if not why ?
Or any suggestion How i can implement that
回答1:
You could use an online cron service to do that. Simply set it to fire your script every week....
- EasyCron
- SetCronJob
- My Web Cron
回答2:
One alternative is to add some code like this (untested!) to your web page so it runs whenever the site is visited:
<?php
$fp = @fopen('.lastjob', "r+");
if (flock($fp, LOCK_EX)) {
$lastjob = fgets($fp);
if (!$lastjob || (time() - $lastjob) > 604800) {
// send out the emails here
ftruncate($fp, 0);
fwrite($fp, time());
fflush($fp);
flock($fp, LOCK_UN);
}
}
fclose($fp);
It checks whether the last job was performed more than a week ago, and if so, it sends out the emails.
来源:https://stackoverflow.com/questions/25787032/how-to-send-dynamic-content-email-without-cron-job