如果无法访问 php.ini(假设 php -v >= 5.3 & mail.add_x_header = 1),或者无法修补邮件,是否有办法更改 X-Php-Originating-Script header 当使用 php 的 mail()
函数时?
我所做的小研究表明,在调用 mail()
之前更改 $_SERVER['PHP_SELF']
可以解决问题,但这对我来说不起作用.
我还尝试直接设置 X-Php-Originating-Script,这导致了额外的“X-Php-Originating-Script” header 。
本例的目标是防止上述电子邮件的收件人泄露脚本命名法的详细信息。
谢谢!
最佳答案
根据 PHP 手册 ( PHP Manual >> Function Reference >> Mail Related Extensions >> Mail >> Installing/Configuring ),可以使用 php.ini
或 .htaccess
文件关闭该 header ,这将阻止任何人从您的网站收集信息邮件 header ,而无需访问 php.ini 文件。
关闭它的设置是:
mail.add_x_header
bool
Add
X-PHP-Originating-Script
that will include UID of the script followed by the filename.
这将使实际的行需要禁用它:
mail.add_x_header 0
此设置标记为 PHP_INI_PERDIR 模式(自 PHP 5.3.0 起可用)。 PHP_INI_PERDIR 表示“条目可以在 php.ini、.htaccess、httpd.conf 或 .user.ini(自 PHP 5.3 起)中设置。”
对于.htaccess
:
php_flag mail.add_x_header Off
我还没有亲自测试过这个,所以 YMMV。
关于php - 混淆 X-Php-Originating-Script,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15426388/