X-PHP-Originating-Script
is the header PHP adds (a commenter also mentioned that).
This does not mean X-PHP-Script
does not exist. cPanel, for instance, uses it to identify messages sent by the nobody
user. You may have seen the X-PHP-Script
header, but it was not added by PHP itself.
cPanel itself adds this header internally. You may alter this behavior by using the Exim Configuration Manager Advanced Editor in cPanel. One such way is to use system-wide message filtering. However, cPanel's documentation does not recommend doing so. It may cause severe performance issues or cause email messaging to stop working entirely.
This particular header is used to identify messages being delivered to Exim within cPanel. It is one of the possible ways to identify the source of a message to cPanel's mail transfer agent for security purposes. It is unlikely that shared server hosts will allow you to modify configurations of this type in cPanel.
It is possible to make PHP's mail()
add it by:
Modifying PHP's source and using runkit7_function_redefine
are possible but not generally a feasible or appropriate way to change the behavior of PHP's mail()
. They also require advanced knowledge and significant planning and effort.
Also, a mail transfer agent like Exim Internet Mailer can be configured to add or remove message headers outside of PHP, but this does not modify the behavior of mail()
itself.
There is currently no simple way (as of 2023) to add X-PHP-Script
automatically from within PHP, other than by doing it manually as you mentioned.