Codeigniter 电子邮件错误处理 [英] Codeigniter Email error handling

查看:21
本文介绍了Codeigniter 电子邮件错误处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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 需要为 提供明确的 FALSEemail->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 电子邮件错误处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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