首页 > 解决方案 > 监控日期并向用户发送电子邮件通知

问题描述

我在 OctoberCMS 中创建了一个插件来存储用户信息和产品到期日期。

我想在到期日期接近当前日期时触发事件并向用户发送电子邮件,我如何监控日期(我应该使用 contrib shell 命令)?我该如何处理?

问候,

标签: octobercmsoctobercms-plugins

解决方案


可能你需要cron-jobs https://en.wikipedia.org/wiki/Cron

服务器将根据您在您定义的时间执行调度程序cron-job,在您的情况下,最好每天安排它

现在每天它都会触发你的调度程序>然后它会用你的逻辑调用你的Taskhttps://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

如有任何疑问,请发表评论


推荐阅读