通过电子邮件通知到期日 [英] notify by email on expiry date

查看:74
本文介绍了通过电子邮件通知到期日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个数据库保存有关工人详细信息的记录 例如姓名,国家/地区,签证有效期.

I'm working on a database that saves records for laborers details such as name, nation, visa expiry date.

所以,我想创建一个小脚本来搜索和匹配到期日和今天的日期,并在签证到期前1个月内通过电子邮件向我发送通知.

So, I want to create a little script that searches and matches expiry dates with today's date and send me a notification by email within 1 month before the visa expires.

推荐答案

一个非常粗略的轮廓,假设您已经有一个数据库表.

A very rough outline, assuming you already have a database table.

每天运行一个脚本,该脚本计算出今天减去一个月(在Stratton的答案中解决)并执行select * from databasetable where expirydate = todayminusonemonth.遍历结果集,用目标的特定信息编写一条消息,然后使用php的邮件界面将其发送出去.

Every day run a script that calculates todayminusonemonth (solved in Stratton's answer) and performs a select * from databasetable where expirydate = todayminusonemonth. Iterate over the result set, compose a message with the target's specific information and send it out using php's mail interface.

到目前为止,这是确保脚本每天运行的最简单的解决方案,如果这不是一种选择,则应在db中添加一列以指示已发送邮件.或者可以创建一个额外的表格,列出所有已发送邮件的日子...

It's by far the easiest solution to make sure the script runs every day, if that's not an option a column should be added to the db to indicate that the mail has been sent. Or an extra table listing all days for which mails have been sent could be created...

看到了吗?问题的第一个分解很容易.现在,您可以开始解决每一个局部问题,或者查找每个问题的信息/方法.随时根据您的具体需求提出一个新问题.

See? This first decomposition of the problem was quite easy. Now you can start solving each of these partial problems, or look up information/howtos for each. Feel free to create a new question with more specific needs you may have.

您可能会遇到的一个问题是您的虚拟主机不允许执行cron脚本.

One problem you may run into is that your webhost doesn't allow cron scripts to be executed. A very creative alternative solution using a website monitoring service is explained in I don't have cron jobs on my server. What is an alternative for sending emails without user input?

这篇关于通过电子邮件通知到期日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆