PHP mail() header patch This is a patch to add an informational header to messages sent from PHP via the mail() function. This can help to track which script on a server was used to send a message, and which client caused it to be sent. The header added has the form: X-PHP-Script: for For example: X-PHP-Script: www.example.com/~user/testapp/send-mail.php for 10.0.0.1 If the connection appears to have come via a proxy cache (i.e. has an "X-Forwarded-For" header), is a list of addresses (the addresses in X-Forwarded-For, then the 'real' remote address). This patch is a modified version of Steve Bennett's patch which can be read at http://www.lancs.ac.uk/~steveb/patches/php-mail-header-patch/ since his patch only available for version 4.3.4 during the time I checked and also won't be working for mail function example 1 as listed at http://www.php.net/manual/en/function.mail.php Special thanks to: (1) Steve Bennett for his patch (2) Stefan Esser from hardened-php.net to report a security issue regarding PHP_SELF in headers (http://www.hardened-php.net/advisory_142006.139.html) (3) Alexey Koscheev from koscheev.ru regarding using zend_is_auto_global to properly access $_SERVER (24 Jan 2015) Reference: http://grokbase.com/t/php/php-internals/033hwqce0z/server-registration-issue