如何安排发送电子邮件

编程入门 行业动态 更新时间:2024-10-11 03:22:01
本文介绍了如何安排发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用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?

推荐答案

如果您想做一个邮件队列系统,我建议您看一下 PEAR :: Mail_Queue 和相关的教程.

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)

希望有帮助.

更多推荐

如何安排发送电子邮件

本文发布于:2023-11-23 19:17:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622583.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送电子邮件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!