用于结果处理的 phpmailer 错误代码 [英] phpmailer error codes for outcome processing

查看:66
本文介绍了用于结果处理的 phpmailer 错误代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建邮件输出功能,就目前而言,它运行正常.但是,我想区分各种潜在(高级)结果,以确定当前发送尝试后每条消息会发生什么.

I am building a mailout capability and it is working OK as far as it goes. However, I want to distinguish between various potential (high level) outcomes in order to determine what happens to each message after the current send attempt.

这一定是一个常见的要求,所以我似乎遗漏了一些非常明显的东西,但我找不到任何可以解决它的东西,无论是在这里还是通过 Google 或在 PHPMailer 网站上,或...可能是因为关于特定错误的问题太多,我在所有其他结果中都找不到任何有用的信息.

This must be a common requirement so I seem to be missing something pretty obvious, but I can't find anything that addresses it, either here or via Google or on PHPMailer site or .. . Possibly because there are so many questions about specific errors that I just can't find anything useful in all the other results.

在非常高的水平上:
尝试发送,并评估由此产生的错误/结果.确定此消息是否已发送、必须稍后重试或永久失败.
- 成功 -> 将消息状态更新为已发送:确定"
- 已发送,但存在一些问题(例如,一个收件人失败,其他人处理正常)-> 'SENT: some error'
- 失败,由于临时问题(例如连接问题、附件打开)-> 'TRY LATER'
- 失败,由于特定于消息的问题,我们不应该尝试重新发送->失败:一些错误"

At very high level:
Attempt send, and assess resulting error/result. Identify whether this message has been sent, must be retried later, or failed permanently.
- success -> update message status as 'SENT: OK'
- sent, but some issues (e.g. one recipient failed, others processed OK)-> 'SENT: some error'
- failed, due to temporary problem (e.g. connection problem, attachment open) -> 'TRY LATER'
- failed, due to message-specific problem that we should NOT try to resend-> 'FAILED: some error'

因为我无法找到现有资源,例如一个错误表,我花了一些时间研究 phpmailerException 代码以尝试自己构建一个,但这并不简单,因为 a) 它们似乎不是按照这种分组逻辑设计的,b) 它是不容易唯一识别特定错误:PHPMailer 提供了人性化的消息,这些消息在不同的语言中是不同的,而不是可识别的代码 - 考虑到我的解决方案需要跨不同语言的安装工作,这是一个问题!

As I was unable to find an existing resource with e.g. a table of errors, I spent some time working through the phpmailerException code to try to build one myself, but it's not simple because a) they don't appear to have been designed in terms of this kind of grouping logic, b) it is not easy to uniquely identify a particular error: PHPMailer provides human-friendly messages, which are different in different languages, rather than an identifiable code - given that my solution will need to work across different language installations that's a problem!

显然,SMTP 本身提供了一系列错误代码,我可能会将其用于此目的,但我如何通过 PHPMailer 访问这些代码?(这对我有用,因为我此时只使用 SMTP - 但是,如果使用其他消息传输,如 sendmail,这将不起作用,所以我更喜欢 PHPMailer 解决方案)

Obviously SMTP itself provides a range of errorcodes which I could potentially use for this purpose, but how do I access these via PHPMailer? (This would work for me as I only use SMTP at this point - however, this would NOT work if other message transport like sendmail was used, so I would prefer a PHPMailer solution)

推荐答案

如果你想要单独地址的单独结果代码,你真的需要单独发送每条消息.如果您确实在某些收件人上遇到错误,它们将列在 ErrorInfo 属性中 - 查看 smtpSend 函数以查看错误字符串是如何组合的.我同意解析这些信息并不是特别容易.PHPMailer 中的错误消息通常更多是针对开发人员而不是最终用户,因此翻译并不那么重要.如果您启用异常而不是仅依赖返回值,您可以获得更多关于错误的信息.

If you want individual result codes for individual address, you really need to send each message separately. If you do get errors on some recipients, they will be listed in the ErrorInfo property - look in the smtpSend function to see how the error string is assembled. I agree that it's not especially easy to parse that info out. The error messages in PHPMailer are generally more for the developer than the end user, so the translations are not that significant. You can get slightly more information about errors if you enable exceptions rather than relying only on return values.

这篇关于用于结果处理的 phpmailer 错误代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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