dqw7121 2012-02-04 00:38
浏览 7
已采纳

如何管理PHP中的电子邮件弹跳和错误?

What would be the best way to manage the emails bounces/errors if you are building a web-mass-mailing software ? I plan to use PHP for that.

Before someone start screaming, yes, the lists will be from valid customers who have opt-in.

I know there are desktop software or third party website that can manage such things. I would like to display it with a design similar to the current CMS's visual and be accessible in there.

If the only solution is to connect to a mail server and read the bouncing back messages, then I will head that way. Then, how would you parse the data to flag that email as "invalid"?

Thank you

  • 写回答

1条回答 默认 最新

  • doujia6433 2012-02-04 01:42
    关注

    One possible thing you could do aside from having a PHP script read mail from a pop/imap server would be to pipe incoming mail for a certain address to a php script. See Google

    You would then read the entire contents of the message in by doing something like $email = file_get_contents('php://stdin'); I've installed the php extension mailparse to assist in parsing RFC emails, but there are other options available. You don't even necessarily have to use anything to parse the message.

    Once you have the message, there are a number of indicators you can use to try to flag a message as a bounch. First, see the Wikipedia article about Non Delivery Reports, specifically Format and RFC 6522 - The Multipart/Report Media Type for the Reporting of Mail System Administrative Messages. You can also check for common headers in the message such as X-Failed-Recipients or Diagnostic-Code.

    Once you've determined a message as a bounce in the PHP mail processor, you can take appropriate action and set a flag in the database related to that email. Mind you, some errors may not mean the address is no good. For example, if a mail server is down for a few days, your MTA may give up, but it doesn't mean the address is no good. Also a user's mailbox could be full.

    It wouldn't be a bad idea to log a copy of the bounced message so it could be checked by a person if necessary to diagnose an issue or reverse the flagging or a particular email address.

    Here are some additional references:

    http://forums.theplanet.com/lofiversion/index.php/t89873.html (note Improvement possibility 2)
    https://stackoverflow.com/questions/5700034/how-do-i-process-a-bounce-email-to-find-the-error-code
    Bounce Email handling with PHP?

    Hope that helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题