如何安排发送电子邮件 [英] How to schedule emails to send out

查看:105
本文介绍了如何安排发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用PHP,我有一个查询,该查询遍历数据库,以在一天中的特定时间查找具有提醒触发器的待处理任务.我有一个cronjob,它每10分钟运行一次,并检查数据库中是否有将"remind_me"字段设置为在接下来的10分钟内关闭的行.如果确实找到了什么,什么是将包含任务信息的电子邮件排队的最佳方法是什么?

Using PHP, I have a query that goes through my DB looking for pending tasks with reminder triggers at certain times of the day. I have a cronjob that runs every 10 mins and checks the DB for any rows that has "remind_me" field set to go off within the next 10 mins. If it does find something, what's the best way to queue an email with the task information?

我想我需要某种消息队列系统,但是电子邮件部分如何工作?我是否需要另一个每分钟运行一次的cronjob来检查队列系统?

I guess I'll need some sort of message queue system, but how does the email part work? Will I need another cronjob that runs every minute to check the queue system?

推荐答案

如果您想做一个邮件队列系统,我建议您看一下

If you want to do a mail queue system I would suggest you take a look at PEAR::Mail_Queue and the associated tutorial.

您可以在运行10分钟脚本时使邮件排队,并可以通过cron作业每10分钟清空一次邮件队列.您还可以每分钟清空一次邮件队列,并在有问题的邮件队列中实施不发送之前"的时间.

You would be able to queue up mail when your 10minute script ran, and have the mail queue emptied every 10 minutes via a cron job. You could also have the mail queue emptied every minute and implement a 'do not send before' time in the queue on the mail in question.

或者,您可以每分钟运行一次检查脚本,以检查最近十分钟内是否有提醒事项,然后立即发送邮件,从而无需队列系统.

Alternatively you could run your checking script every minute checking for items that a reminder is due in the last ten minutes and send the mail immediately, which removes the need for a queue system.

这可以通过记录上次发送警报的时间来实现(这样您就不会错过任何警报,也不会两次发送警报)

This could be implemented by a record of when you last sent alerts (so that you don't miss any and don't send alerts twice)

希望有帮助.

这篇关于如何安排发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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