如何使用 PHP 处理邮件发送错误
我正在构建一个用于发送新闻通讯的 symfony 模块。 这个想法是建立一个地址队列列表来接收邮件,然后使用 cron 作业,一次发送 50 个邮件。
我现在不知道如何做是阅读当电子邮件地址不存在或邮件已满时服务器发回的邮件传送报告。 这个想法是存储这些错误报告并清理地址列表。
知道如何实施吗?
I am building a symfony module for sending newsletters. the idea is to build a queue list of adreeses to receice the mail and then ,with a cron job, send let's say 50 at a time.
What i don't now how to do is to read the Mail Delivery reports that are sent back by the server when an email adress doesn't exist or the mail is full. The idea is to store these error reports an clean the adress list.
Any ideea how to implement that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当阅读“退回的收件箱”时,您可以使用这样的类来实际解析邮件并查看返回的状态(例如永久或临时错误):
http://www.phpclasses.org/browse/package/2691.html
要真正准确地解析邮件会给你带来困难,因为不所有邮件服务器都是相似的,有些会向您发送带有“永久”标志的“邮箱已满”错误,而其他邮件服务器可能会告诉您错误“用户不存在”是“临时”的。
我尝试过一次解决方案,最终设置了我自己的解析器,连接到一个包含可能的服务器回复(以及它们的“真实”含义:)的巨大数据库。
When reading the "bounced inbox", you can use a class like this to actually parse the mail and see what status was returned (e.g. permanent or temporary error):
http://www.phpclasses.org/browse/package/2691.html
To really parse a mail accurately will give you a hard time, as not all mailservers are alike and some will send you a "mailbox full"-error marked with a "permanent" flag while others may tell you that the error "user doesn't exist" is "temporary".
I tried a solution for this once and ended up setting up my own parser connected to a huge database containing possible server replies (and their "real" meaning :).
您可以在发送时使用回复地址。 因此,绑定的电子邮件将发送到此 ID。 您还可以创建另一个 PHP 脚本,该脚本将 阅读此“回复”电子邮件收件箱并从中获取 ID。 然后您可以从您拥有的列表中删除该 ID。
You can use a reply to address while sending. So bouned emails will be sent to this id. You can also create another PHP script which will read this "reply to" email inbox and get the id from it. You can then remove this id from the list you have.