So easy:PHP配置把错误日志以邮件方式发送方法(Windows系统)
(望结交天下才士 ,Contact:UVEgMTkwNDUyOTQzOA==)
当系统发生了很严重的问题,需要立刻发送给管理员。可以通过 error_log() 将错误以邮件形式发送到邮箱。
在 php.ini 中设置:
1 sendmail_from = 472323087@qq.com
然后设置:
1 sendmail_path = "G:\sendmail\sendmail.exe -t"
其中:G:\sendmail\sendmail.exe 是邮件客户端的地址。
1 <?php 2 //关闭错误显示 3 ini_set('display_errors', 0); 4 //开启错误日志功能 5 ini_set('log_errors', 'on'); 6 //显示所有错误 7 error_reporting(-1);
//发送错误
error_log('当前系统被攻击,产生了致命错误', 1, '472323087@qq.com'); //参数 1 表示以邮件形式发送错误