监控日期并向用户发送电子邮件通知

问题描述 投票:0回答:1

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

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

问候,

octobercms octobercms-plugins
1个回答
1
投票

可能你需要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这些记录

您可以按照本指南https://octobercms.com/docs/setup/installation#crontab-setup将master cron作业添加到服务器

然后你可以写你逻辑你想要做的事情https://octobercms.com/docs/plugin/scheduling#introduction

如果有任何疑问请评论

© www.soinside.com 2019 - 2024. All rights reserved.