Codeigniter Email error handling(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 需要为 提供明确的 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 电子邮件错误处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Codeigniter 电子邮件错误处理
基础教程推荐
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何替换eregi() 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
