octobercms - 监控日期并向用户发送电子邮件通知
问题描述
我在 OctoberCMS 中创建了一个插件来存储用户信息和产品到期日期。
我想在到期日期接近当前日期时触发事件并向用户发送电子邮件,我如何监控日期(我应该使用 contrib shell 命令)?我该如何处理?
问候,
解决方案
可能你需要cron-jobs
https://en.wikipedia.org/wiki/Cron
服务器将根据您在您定义的时间执行调度程序cron-job
,在您的情况下,最好每天安排它。
现在每天它都会触发你的调度程序>然后它会用你的逻辑调用你的Task
(https://octobercms.com/docs/plugin/scheduling#introduction )。
逻辑
您将获取条件如下的记录:
current_date + 1/2/3 day
将该日期转换为时间戳并存储到变量future_date
并在字段上添加条件expiry_date
expiry_date > today_time_stamp AND expiry_date < future_date
它将为您提供即将在未来 1/2/3 天到期的记录
现在
notify [send email]
或这些fire event
记录
您可以将主 cron 作业添加到您的服务器,只需按照本指南 https://octobercms.com/docs/setup/installation#crontab-setup
然后你可以写你想要如何完成的逻辑 https://octobercms.com/docs/plugin/scheduling#introduction
如有任何疑问,请发表评论
推荐阅读
- cloud - 雾计算环境下卸载决策与任务调度的区别
- oracle - 如何在约束中正确使用 REGEXP_LIKE
- html - 表单复选框状态未显示在 POST 请求(烧瓶)中
- spring - Spring boot 将接收到的 MultiPartFile 转发到 Feign Client
- keras - keras_history[0].supports_masking 做什么?
- java - 如何将数据带到另一个班级
- php - 致命错误:不支持的媒体类型:通过 php/graphaware 查询 neo4j
- reactjs - 无法在 Edge 浏览器中获取
- django - 如何在 django 的模板自定义过滤器中传递带有静态文本的动态变量
- python - Arm Cortex Bootloader 调试技巧