Php Codeigniter在网站出现错误时发送电子邮件

Php Codeigniter在网站出现错误时发送电子邮件,php,codeigniter,Php,Codeigniter,当我的网站在生产中出现错误时,结果只能显示在日志目录中。当我的系统出现错误时,系统能否自动发送电子邮件 我已经在这样的库中创建了一个类 class MY_Exceptions extends CI_Exceptions { function __construct() { parent::__construct(); } function log_exception($severity, $message, $filepath, $line) { if (ENVIRO

当我的网站在生产中出现错误时,结果只能显示在日志目录中。当我的系统出现错误时,系统能否自动发送电子邮件

我已经在这样的库中创建了一个类

class MY_Exceptions extends CI_Exceptions {

function __construct()
{
    parent::__construct();
}

function log_exception($severity, $message, $filepath, $line)

{   
    if (ENVIRONMENT === 'production') {
        $ci =& get_instance();

        $ci->load->library('email');
        $ci->email->from('your@example.com', 'Your Name');
        $ci->email->to('someone@example.com');
        $ci->email->cc('another@another-example.com');
        $ci->email->bcc('them@their-example.com');
        $ci->email->subject('error');
        $ci->email->message('Severity: '.$severity.'  --> '.$message. ' '.$filepath.' '.$line);
        $ci->email->send();
    }


    parent::log_exception($severity, $message, $filepath, $line);
}
}


但它仍然不起作用

我把它放在应用程序/核心中,而不是应用程序/库中。它正在工作

尝试使用
set\u error\u handler()
您可以扩展异常类可能无法发送重复的电子邮件。我应该配置协议、主机等吗@厌恶