How to send dynamic content email without cron job

早过忘川 提交于 2019-12-11 11:08:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!