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

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

报告相同问题?

悬赏问题

  • ¥30 关于#opencv#的问题:使用大疆无人机拍摄水稻田间图像,拼接成tif图片,用什么方法可以识别并框选出水稻作物行
  • ¥15 Python卡尔曼滤波融合
  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1