PHP配置把错误日志以邮,件方式发送方法

发布时间:2017-08-07 12:04 来源:互联网 当前栏目:web技术类

   这篇文章主要介绍了PHP配置把错误日志以邮件方式发送方法(Windows系统),本文给出了配置示例和使用例子,需要的朋友可以参考下

  当系统发生了很严重的问题,需要立刻发送给管理员。可以通过 error_log() 将错误以邮件形式发送到邮箱。

  在 php.ini 中设置:

   代码如下:

  sendmail_fro

[www.la240.com/html2017/1/7/]
m = [email protected]

  然后设置:

  代码如下:

  sendmail_path = "G:sendmailsendmail.exe -t"

  其中:G:sendmailsendmail.exe 是邮件客户端的地址。

  代码:

  代码如下:

  

  //关闭错误显示

  ini_set('display_errors', 0);

  //开启错误日志功能

  ini_set('log_errors', 'on');

  //显示所有错误

  error_reporting(-1);

  //发送错误

  error_log('当前系统被攻击,产生了致命错误', 1, [email protected]'); //参数 1 表示以邮件形式发送错误

  • 1、
  • 2、
  • 3、
  • 4、
  • 5、
  • 6、
  • 7、
  • 8、
  • 9、
  • 10、
  • 11、
  • 12、
  • 13、
  • 14、
  • 15、
  • 16、
  • 17、
  • 18、
  • 19、
  • 20、
  • 21、
  • 22、
  • 23、
  • 24、
  • 25、
  • 1、
  • 2、
  • 3、
  • 4、
  • 5、
  • 6、
  • 7、
  • 8、
  • 9、
  • 10、
  • 11、
  • 12、
  • 13、
  • 14、
  • 15、
  • 16、
  • 17、
  • 18、
  • 19、
  • 20、
  • 21、
  • 22、
  • 23、
  • 24、
  • 25、