问题描述
CI Email send() 函数只返回 true 或 false.有没有办法获得发送失败的更详细原因?我正在使用 SMTP.
The CI Email send() function only returns true or false. Is there a way to get a more detailed reason as to why a sending failed? I'm using SMTP.
推荐答案
您可以使用电子邮件调试器进一步检查发生的情况:
You can further inspect what happened by using the email debugger:
$r = $this->send(FALSE);
if (!$r)
$this->email->print_debugger()
;
来自 Codeigniter 电子邮件类参考.
如果您需要将调试器输出为字符串,您可以使用 输出缓冲区:
If you need the debugger output as a string, you can just catch the output with an output buffer:
$errors = array();
... # Loop
$r = $this->send(FALSE);
if (!$r) {
ob_start();
$this->email->print_debugger();
$error = ob_end_clean();
$errors[] = $error;
}
... # Loop end
最新版本中的 Codeigniter 需要为 提供明确的 FALSE参数,以便不清除消息和调试,如果传递失败有效地杀死调试器函数错误.email->send()函数的$auto_clear
Codeigniter in more recent versions requires an explicit FALSE for the $auto_clear parameter of the email->send() function in order to not clear the message and the debugging, effectively killing the debugger function if you fail to pass the FALSE.
这篇关于Codeigniter 电子邮件错误处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)