发送 10,000+ 的最佳方式使用 PEAR/Mail_Queue 发送电子邮件
我有一个 cron,它生成整个邮件信息并使用 $mail_queue->put(.....)
放入数据库表中,并可以选择在发送后删除电子邮件。
这是我需要一点帮助的地方:在获得上述信息后,发送电子邮件的最佳方式是什么?使用其他 cron 作业或其他方式立即运行 $mail_queue->sendMailsInQueue()
?
顺便说一句,服务器限制为 100 封电子邮件/分钟。目前,Mail_Queue
的最后一个 csv diff 尚未应用(当前正在处理该问题的支持),因此我无法使用“延迟”选项。
我有一个想法使用 $seconds_to_send 选项,但它是根据 create_time 字段计算的,这没有太大帮助,但它也是一个选项。
任何想法和建议将不胜感激。
I have a cron which generates the whole mail info and puts in a database table using $mail_queue->put(.....)
with an option to delete emails after they're sent.
Here's where I need a little help: What is the best way to send the emails after I have the above info? Running the $mail_queue->sendMailsInQueue()
right away, using other cron job(s) or something else?
The server limit by the way is 100 emails / minute. Currently the last csv diff for Mail_Queue
is not applied (currently working with the support on that), so I can't use the "delay" option.
I had an idea to use the $seconds_to_send
option, but it's calculated on the base of create_time field, which isn't a big help, but it's also an option.
Any ideas and suggestions would be really appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
就我个人而言,我会采用 cron 方式,因为它减少了失败的机会。假设您的邮件服务器停止响应或由于某种其他原因变得不可用。或者,如果您的整个网络离线几个小时,但服务器仍在生成电子邮件,该怎么办?我说使用队列。
至于延迟问题,只需让一个服务/cronjob 每 60 秒接收一次队列,弹出 100 封电子邮件并发送它们,然后退出。您可能会收到一列要发送的电子邮件,但无论您选择什么系统,这种情况都会发生。无论如何,非高峰时段队列会空。
Personally, I would go the cron way because it gives less opportunity for failure. Say your mail server stops responding or for some other reason becomes unavailable. Or what if your entire network goes offline for a few hours, but the servers are still generating emails. I say use the queue.
As for the delay thing, just have a service/cronjob pick up the queue every sixty seconds, pop 100 emails and send them, then quit. You might get a queue of emails to be sent but that's going to happen no matter what system you choose. The queue will empty during off-peak hours, anyways.
使用两个脚本。第一个脚本用于使用您需要发送的电子邮件填充您的 mail_queue 表,第二个脚本用于一次性发送 90 封邮件。将第二个脚本设置为大约每 2 分钟左右激活一次。
您也可以升级您的托管计划;-)
use two scripts. one for populating your mail_queue table with the emails you need to send and the second script to send those emails in chunks of 90 mails at a go. set the second script to be activated about every 2 minutes or so.
you could also just upgrade your hosting plan ;-)
为什么你不循环浏览 100 封电子邮件并休息 60 秒。这不会花费您的服务器时间,唯一的缺点是您的脚本运行时间稍长一些。
why you dont loop through 100 emails and sleep for 60seconds. this costs you no servertime, the only downside your script runs a little longer.