Home > Article > Backend Development > How to configure PHP to send error logs by email_PHP tutorial
This article mainly introduces how to configure PHP to send error logs by email (Windows system). This article gives Configuration examples and usage examples, friends in need can refer to it
When a serious problem occurs in the system, it needs to be sent to the administrator immediately. Errors can be emailed to the mailbox via error_log().
Set in php.ini:
The code is as follows:
sendmail_from = 472323087@qq.com
Then set:
The code is as follows:
sendmail_path = "G:sendmailsendmail.exe -t"
Where: G:sendmailsendmail.exe is the address of the email client.
Code:
The code is as follows:
//Close error display
ini_set('display_errors', 0);
//Enable error log function
ini_set('log_errors', 'on');
//Show all errors
error_reporting(-1);
//Sending error
error_log('The current system is under attack and a fatal error occurred', 1, '472323087@qq.com'); //Parameter 1 means sending the error by email