问题描述
我想安排从php脚本发送电子邮件。我想让用户指定日期和时间,然后在指定的日期和时间,我想要自动发送这些电子邮件。如何实现?我正在编写codeigniter。
I want to schedule sending of email from php script. I want user to specify date and time and then on the specified date and time, I want those emails to be sent automatically. How do I implement it? I am working on codeigniter.
推荐答案
一种方法是创建一个scheduled_emails数据库表。将您要排队的所有电子邮件放入其中,包括诸如收件人,主题,邮件和可选标题等列。
One way to do it would be to create a "scheduled_emails" database table. Put all the emails you want to queue in there, including columns such as, recipient, subject, message and optional headers.
然后,您可以设置一个脚本并且发送具有大于当前时间的send_time的任何电子邮件。然后,您可以设置一个cron作业,以运行此脚本。例如每5分钟。
You could then set up a script to look at that table and send any emails that have a "send_time" which is greater than the current time. You could then set up a cron job to run this script every.. 5 minutes for example.
这篇关于在php中计划一封电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!