Home > Article > Backend Development > PHP configuration method to send error logs by email (Windows system), php log_PHP tutorial
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:
Copy code The code is as follows:
sendmail_from = 472323087@qq.com
Then set:
Copy code The code is as follows:
sendmail_path = "G:sendmailsendmail.exe -t"
Among them: G:sendmailsendmail.exe is the address of the mail client.
Code:
Copy 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