0

On Ubuntu 22.04 I have the following in /etc/php/8.1/apache2/php.ini (and have restarted Apache), and in /etc/php/8.1/cli/php.ini:

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On

When I send a mail from a PHP script like this:

<?php
mail('[email protected]','Test message subject','Test message body');
echo 'Mail sent.'; 
?>

It sends and arrives all OK, but there is no mention of any X-PHP-Originating-Script in any log I can find. I have tried setting the mail.log = directive in php.ini to the default, as well as to syslog and to a file in /tmp.

When I run phpinfo(); it confirms the settings are correct.

What am I doing wrong?


EDIT: If I look at the mail headers I receive, I see the X-PHP-Originating-Script: line in there. Perhaps I've misunderstood - is that all the php.ini directive does?

1 Answer 1

1

EDIT: If I look at the mail headers I receive, I see the X-PHP-Originating-Script: line in there. Perhaps I've misunderstood - is that all the php.ini directive does?

Yes. As indicated by the fact that it's named mail.x-add-header. You can probably configure your mailserver to log this to file if you want.

3
  • Thanks - for some reason I had assumed the line under it mail.log = was where the name of the script would be logged, but obviously not as that seems to do nothing. Nov 5, 2023 at 14:40
  • 1
    That's a separate setting - have a look at the documentation. Whilst a lot can be said about PHP, the documentation is fairly good.
    – vidarlo
    Nov 5, 2023 at 14:42
  • Yes, the fact that it's not logging mail calls is I suppose another issue. But if I can do it with postfix header_checks then that's fine I think. Nov 5, 2023 at 14:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .