【发布时间】:2021-07-31 10:00:36
【问题描述】:
我正在使用 PHPMailer 发送电子邮件。
在电子邮件的原始消息中,标题包含
X-PHP-Script: /path/to/my/script.php myip6address, myip4address
我在php.ini中编辑了这些设置
[mail function]
mail.add_x_header = 0
add_x_header = 0
在我的php脚本中,当我使用ini_get("mail.add_x_header")时,它返回"0"。
// to try and erase the info from the global server var
$_SERVER = Array();
$mail = new PHPMailer;
$mail->setFrom("me@mysite.com");
$mail->addAddress("foo@gmail.com");
// to try and override it, instead it just appends and keeps the original header
$mail->addCustomHeader("X-PHP-Script", "No.");
$mail->Subject = "This is a test";
$mail->isHTML(true);
$mail->Body = "hello world";
if($mail->send() == false)
{
var_dump("failed to send mail", $mail->ErrorInfo);
}
它仍然会在我发送的每封电子邮件中发送我的脚本位置和我的 IP 地址。
如果我使用 mail() 而不是 PHPMailer,它也会发送它,但我假设 PHPMailer 在后台使用 mail()。
如何完全禁用该标头?
【问题讨论】:
标签: php email header phpmailer email-headers