<small id='YIae7'></small><noframes id='YIae7'>

      1. <tfoot id='YIae7'></tfoot>
        <i id='YIae7'><tr id='YIae7'><dt id='YIae7'><q id='YIae7'><span id='YIae7'><b id='YIae7'><form id='YIae7'><ins id='YIae7'></ins><ul id='YIae7'></ul><sub id='YIae7'></sub></form><legend id='YIae7'></legend><bdo id='YIae7'><pre id='YIae7'><center id='YIae7'></center></pre></bdo></b><th id='YIae7'></th></span></q></dt></tr></i><div id='YIae7'><tfoot id='YIae7'></tfoot><dl id='YIae7'><fieldset id='YIae7'></fieldset></dl></div>
        <legend id='YIae7'><style id='YIae7'><dir id='YIae7'><q id='YIae7'></q></dir></style></legend>
          <bdo id='YIae7'></bdo><ul id='YIae7'></ul>
      2. 使用 crontab 在 yii 中添加剩余电子邮件

        To add remainder email in yii using crontab(使用 crontab 在 yii 中添加剩余电子邮件)

        <small id='N3Fo3'></small><noframes id='N3Fo3'>

        <tfoot id='N3Fo3'></tfoot>
          • <bdo id='N3Fo3'></bdo><ul id='N3Fo3'></ul>
            <legend id='N3Fo3'><style id='N3Fo3'><dir id='N3Fo3'><q id='N3Fo3'></q></dir></style></legend>

                <tbody id='N3Fo3'></tbody>

                <i id='N3Fo3'><tr id='N3Fo3'><dt id='N3Fo3'><q id='N3Fo3'><span id='N3Fo3'><b id='N3Fo3'><form id='N3Fo3'><ins id='N3Fo3'></ins><ul id='N3Fo3'></ul><sub id='N3Fo3'></sub></form><legend id='N3Fo3'></legend><bdo id='N3Fo3'><pre id='N3Fo3'><center id='N3Fo3'></center></pre></bdo></b><th id='N3Fo3'></th></span></q></dt></tr></i><div id='N3Fo3'><tfoot id='N3Fo3'></tfoot><dl id='N3Fo3'><fieldset id='N3Fo3'></fieldset></dl></div>

                • 本文介绍了使用 crontab 在 yii 中添加剩余电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  按照建议,我在 protected/commands 下创建了一个 File MessengerCommand.php 作为

                  as suggested I created a File MessengerCommand.php under protected/commands as

                  class MessengerCommand extends CConsoleCommand
                  {
                      public function run($args)
                      {
                          /* if(ERunActions::runBackground())
                          { */
                  
                         $mail=Yii::app()->Smtpmail;
                          $mail->SetFrom("tsadmin@softthink.com", 'From NAme');
                          $mail->Subject    ="hello";
                          $mail->MsgHTML("haiii workd");
                          $mail->AddAddress("rajesh.udutha@itaugments.com", "");
                          if(!$mail->Send()) {
                              echo "Mailer Error: " . $mail->ErrorInfo;
                          }else {
                              echo "Message sent!";
                          }
                  }
                  }
                  

                  并添加 yiic 命令为

                  $path = dirname(__FILE__);
                  //echo $path;
                  shell_exec( $path . "/protected/yiic messenger" );
                  

                  它会在我加载网站时触发电子邮件....

                  and it will trigger email when I load the site ....

                  但我不想刷新网站..我需要让它在后台运行..请帮助我.

                  but I dont wanna refresh the site ..I need to make this to run in background ..Please help me.

                  推荐答案

                  您可以使用 yii 控制台应用程序 来完成你的任务.

                  You can use yii console applications to accomplish your task.

                  protected/commands中创建一个带有Command后缀的新文件,例如:MessengerCommand.php:

                  In protected/commands create a new file with Command sufix, for example: MessengerCommand.php:

                  <?php
                  class MessengerCommand extends CConsoleCommand
                  {
                  .......
                  

                  在班级 MessengerCommand 你有几个创建选项命令动作.在此示例中,我们将覆盖 run 方法:

                  In class MessengerCommand you have several options to create the command action. In this sample we will override run method:

                  public function run($args)
                  {
                          $birth_month = date("m");
                          $birth_day = date("d");
                          $criteria = new CDbCriteria;
                          $criteria->condition = "birth_month = $birth_month and birth_day = $birth_day";
                          $listScheduledRecords = Table::model()->findAll($criteria);
                          foreach($listScheduledRecords as $scheduled_record):
                              $this->send($scheduled_record);
                          endforeach;
                  }
                  
                  public function send($scheduled_record)
                  {
                      ....
                      your logic to send your email
                      ....
                  }
                  

                  protected 目录下,创建一个文件:messenger.php.该文件将作为命令执行器:

                  In protected dir, create a file: messenger.php. This file will be the command executer:

                  <?php
                  $path = dirname(__FILE__);
                  $output = shell_exec( $path . "/./yiic messenger" );
                  echo $output;
                  

                  要在 Linux/Unix 上进行测试,请在控制台/终端中运行:

                  To test it, on Linux/Unix, run in console/terminal:

                  cd /.../.../...your_protected_path 
                  php messenger.php
                  

                  要在 Windows 上测试,您需要参考您的 php.exe 位置路径或在您的系统环境变量中设置 php.exe 和 在 Windows 上使用 yiic 等价

                  To test on Windows, you need to refer to your php.exe location path or set php.exe on your system environment variables and use yiic equivalence for Windows

                  要安排自动任务,在此示例中,每日执行,在 Linux/Unix 上,您可以使用 cron 作业:

                  To schedule automatic task, in this sample, daily execution, on Linux/Unix, you can use cron jobs:

                  在控制台/终端:

                  crontab -e
                  

                  在 cron 文件中,添加计划任务,每天,在 9h00.记住 cron 语法:#minute hour day of month month day of week 命令

                  In cron file, add the scheduled task, daily, at 9h00. Remember cron sintax: # minute hour day of month month day of week command

                  0   9  *  *  * php /full_path/protected/messenger.php
                  

                  保存文件并退出.

                  要在 Windows 上安排自动任务,参考到他们在 Internet 上的文档/帮助.

                  To schedule automatic task on Windows, refer to their docs / help on Internet.

                  如果有错误,Yii Console应用程序使用自己的配置文件(protected/config/console.php).常见的错误是protected/config/console.php中的db连接、组件、模块错误.

                  If you have errors, Yii Console applications use their own config file (protected/config/console.php). Common mistakes are wrong db connection, components, modules in protected/config/console.php.

                  这篇关于使用 crontab 在 yii 中添加剩余电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    <tbody id='PucBX'></tbody>
                  <i id='PucBX'><tr id='PucBX'><dt id='PucBX'><q id='PucBX'><span id='PucBX'><b id='PucBX'><form id='PucBX'><ins id='PucBX'></ins><ul id='PucBX'></ul><sub id='PucBX'></sub></form><legend id='PucBX'></legend><bdo id='PucBX'><pre id='PucBX'><center id='PucBX'></center></pre></bdo></b><th id='PucBX'></th></span></q></dt></tr></i><div id='PucBX'><tfoot id='PucBX'></tfoot><dl id='PucBX'><fieldset id='PucBX'></fieldset></dl></div>

                • <tfoot id='PucBX'></tfoot>
                    <legend id='PucBX'><style id='PucBX'><dir id='PucBX'><q id='PucBX'></q></dir></style></legend>
                      <bdo id='PucBX'></bdo><ul id='PucBX'></ul>

                            <small id='PucBX'></small><noframes id='PucBX'>