Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error_log passing parameter to sender

Tags:

When I use function error_log with $message_type = 1 - sent by email, I need to pass to sendmail extra parameter "-f" . $sendermail

Is there way which I can pass parameter to sender, same way as it can be done with mail and $additional_parameters?

Documentation says

This message type uses the same internal function as mail() does.

But I can't see quick way how to do it.

like image 389
Zdenek Machek Avatar asked May 24 '16 08:05

Zdenek Machek


1 Answers

As far as a "quick" way to do it is concerned, presuming you mean passing extra arguments or the like, then no. Take a look at the source code for error_log, noticing that NULL is passed explicitly to the parameter in question for the mail function:

if (!php_mail(opt, "PHP error_log message", message, headers, NULL)) {

Other than using set_error_handler as others have mentioned, you could try using the runtime configuration mail.force_extra_parameters (see docs).

Force the addition of the specified parameters to be passed as extra parameters to the sendmail binary. These parameters will always replace the value of the 5th parameter to mail(), even in safe mode.

I have used this before, with the caveat of it overriding options elsewhere so you may have to consider whether it's beneficial to you. For instance, this is what I use in a .conf include on my apache dev server:

# force envelope sender and name and in turn ignore any passed in to PHP mail() function
php_admin_value mail.force_extra_parameters "-f [email protected] -F \"Development: leonard\""
like image 159
LeonardChallis Avatar answered Oct 11 '22 08:10

LeonardChallis