简体   繁体   中英

How to hide X-PHP-Script header using PHP mail?

I run a PHP script that sends mails. In header there is an information about script's path. Is there a way to hide it? Is there a way to hide or change the name of a domain from that I send a mail?

Try overwriting it to null by adding it as a header:

$headers = 'X-PHP-Script: ';
mail($to, $subject, $message, $headers);

Alternative, you could edit the contents of the header as explained by this tutorial .

Please contact your hoster about the options you have here. It's a security related setting and it's not always intended that you can disable/change it.

Try this - it work

// prevent user/script details being exposed in X-PHP-Script header 
$oldphpself = $_SERVER['PHP_SELF']; 
$oldremoteaddr = $_SERVER['REMOTE_ADDR'];
$_SERVER['PHP_SELF'] = "/"; 
$_SERVER['REMOTE_ADDR'] = $_SERVER['SERVER_ADDR']; 

// send the email 
mail($to, $subject, $message[, $additional_headers[, $additional_parameters]]) 

// restore obfuscated server variables 
$_SERVER['PHP_SELF'] = $oldphpself; 
$_SERVER['REMOTE_ADDR'] = $oldremoteaddr;

The hosting company knows why they want these headers - to spare themselves from spammers. They usually do not want allow you to change it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM