How to change the subject of my php error message?

I have the following:

error_log("big error!!", 1, my email address); 

When the message is delivered, the message "PHP error_log" is indicated in the subject line.

Can someone show me how to customize the subject line?

+6
source share
2 answers
 error_log("Error message", 1, " me@example.com ", "Subject: My custom subject"); 

The fourth error_log parameter allows you to specify custom headers from which Subject is the subject of the email message.

+12
source

Thanks niet-the-dark-absol !

I was able to generate this from your header splitting recommendations.

 <?php $dateTime=date("Y_m_d_H_i_s"); $headers = "From: SOME ROBOT < somerobotyouusedtoknow@somecompany.com >\r\n" . "Reply-to: SOME HUMAN < somehumanyoudoknow@somecompany.com >"; "Subject: My custom subject on including date of: " . $dateTime . "\r\n" . $emailto = " JayRizzo@somecompany.com "; $emailbody = "This is the body of the email: Error message"; error_log($emailbody, 1, $emailto, $headers); ?> 

I got the correct answer and was able to change more than just a Subject or Reply-to or From address.

I publish this only because all I find is that you cannot change more than one heading at a time, and this proves it wrong. (unless that improves the version of PHP I'm using)

Note: My PHP version:

~: php -v

PHP 7.2.0RC6 (cli) (built: Nov 12, 2017 08:50:58) (NTS)

Copyright (c) 1997-2017 PHP Group

Zend Engine v3.2.0-dev, Copyright (c) 1998-2017 Zend Technologies

0
source

Source: https://habr.com/ru/post/921907/


All Articles