dongwenghe2416 2016-01-14 17:53
浏览 63
已采纳

让cronjobs在Yii2的基本模板中发送期刊电子邮件的最佳方法是什么?

I have a Web Application using Yii2 and I want to have a cronjob sending periodical emails like digests and such.

What is a good approach to implement that using YiiFramework 2.0 e-mail structure.

Edit1: It is important to say that I am using the basic template and not the advanced one

  • 写回答

1条回答 默认 最新

  • doujianchao7446 2016-01-14 18:43
    关注

    Use the console component of Yii2. Here is a decent intro for using the console

    You set up your function as you would if it were on the web application. Build and generate your email and then set a bash script to run on a cron, which calls your function and generates and sends the email. You can log errors and success of the script also. I send them to my email.

    Set up you confiruation for DB and anything else using config/console.php that's important.

    Your controllers are in commands folder.

    Take a look at https://github.com/yiisoft/yii2-app-basic/blob/master/commands/HelloController.php

    Call this file through the console and it will return the message param.

    When you build your function to send emails, get it to send you an email with success/failure. I always build my controllers in the application first to check that they work, then migrate them into the commands.

    More help on the console is here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路