简体   繁体   English

CakePHP每天发送电子邮件

[英]CakePHP send emails daily

I am new to CakePHP and I am making an application where users fill out forms and then other users who are specified on the form have to add to the data. 我是CakePHP的新手,我正在创建一个用户填写表单的应用程序,然后在表单上指定的其他用户必须添加到数据中。 At the end of each day I want to send an email to all users who have been referenced on forms that day and tell them how many new forms they need to add information to. 在每天结束时,我想向当天在表单上引用的所有用户发送一封电子邮件,并告诉他们需要向其添加多少新表单。

I know how to run my query to figure out who I need to email and how to construct the email, but how do I make it happen once a day or at any set time? 我知道如何运行我的查询以确定我需要通过电子邮件发送电子邮件以及如何构建电子邮件,但我如何在一天或任何设定时间实现? I have found something about cron jobs in my research but I don't fully understand or know if that will work for me. 我在研究中发现了一些关于cron工作的事情,但我并不完全理解或知道这对我有用。 I am working in a Windows environment and launching my app on a heroku server currently. 我目前在Windows环境中工作,并在heroku服务器上启动我的应用程序。

Thanks for any info! 感谢您的任何信息!

Cheers, Jon 干杯,乔恩

Although this question is not really related to CakePHP but rather to Heroku, I suggest you install that Heroku Scheduler Addon . 虽然这个问题与CakePHP没有关系,而是与Heroku有关,但我建议您安装Heroku Scheduler Addon

Once installed, you can write a shell script, such as follows: 安装完成后,您可以编写一个shell脚本,如下所示:

#!/bin/sh

php -f path_to/your_php_file/which_sends_emails.php

and name it sendemailjob.sh or something. 并将其命名为sendemailjob.sh或其他东西。 Make it executable by 让它可执行

sudo chmod +x sendemailjob.sh

After that, you just need to tell Heroku Scheduler to daily execute that file. 之后,您只需要告诉Heroku Scheduler每天执行该文件。 Should not be too much magic. 不应该是太多的魔法。

Although I am not quite sure whether you actually have shell access since you're on Windows, maybe there is a different solution for Windows. 虽然我不确定你是否真的有shell访问,因为你在Windows上,可能有一个不同的Windows解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM