我知道我在这里做了些蠢事,但我无法理解。我正在使用以下内容发送电子邮件:
$headers = "MIME-Version: 1.0
From: ".$from_email."
Bcc: ".$bcc_email."
";
mail($email, $message['subject'], $message['content'], $headers);
其中$from_email = 'no-reply@mydomain.com'
消息来自地址错误。完整标题如下:
Return-path: <cli@hostxxx.com>
Envelope-to: xxx@email.com
Delivery-date: Tue, 20 Nov 2012 11:01:34 -0500
Received: from cli by cli@hostxxx.com with local (Exim 4.69)
(envelope-from <cli@hostxxx.com>)
id 1TaqGI-000232-IJ
for xxx@email.com; Tue, 20 Nov 2012 11:01:26 -0500
To: xxx@email.com
Subject: Fairway Solutions - Your new password
MIME-Version: 1.0
From: no-reply@mydomain.com
Bcc: support@mydomain.com
Message-Id: <E1TaqGI-000232-IJ@host.com>
From: cli@hostxxx.com
Date: Tue, 20 Nov 2012 11:01:22 -0500
令人讨厌的是,我可以看到From正确通过,但就像收到的是覆盖了主机的信息。我在服务器级别丢失了什么吗?
我也尝试在php.ini文件中设置它(ini_set(sendmail_from,no-reply@mydomain.com);
)并且它没有任何区别。
TA
答案 0 :(得分:2)
您可以尝试添加其他标头,例如X-Sender:
$headers = 'Content-type: text/html; charset=iso-8859-1' . "\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= "From: $sender<" . $sender . ">" . "\r\n";
$headers .= "X-Sender: $sender<" . $sender . ">" . "\n";
$headers .= "X-Mailer: PHP " . phpversion() . "\n";
$headers .= "X-Priority: 3" . "\n";
$headers .= "X-Sender-IP: " . $_SERVER['REMOTE_ADDR'] . "\n";
$headers .= "Return-Path: $sender<" . $sender . ">" . "\r\n";
$headers .= "Reply-To: $sender<" . $sender . ">" . "\r\n";