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

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

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)