2012-11-20 71 views
1

我知道我在这里做了一些愚蠢的事情,但我无法弄清楚。我使用以下发送邮件:PHP sendmail地址显示不正确

$headers = "MIME-Version: 1.0 
    From: ".$from_email." 
    Bcc: ".$bcc_email." 
    "; 
    mail($email, $message['subject'], $message['content'], $headers); 

其中$from_email = '[email protected]'

消息从地址来通过与错。下面的完整标题:

Return-path: <[email protected]> 
Envelope-to: [email protected] 
Delivery-date: Tue, 20 Nov 2012 11:01:34 -0500 
Received: from cli by [email protected] with local (Exim 4.69) 
    (envelope-from <[email protected]>) 
    id 1TaqGI-000232-IJ 
    for [email protected]; Tue, 20 Nov 2012 11:01:26 -0500 
To: [email protected] 
Subject: Fairway Solutions - Your new password 
MIME-Version: 1.0 
     From: [email protected] 
     Bcc: [email protected] 
Message-Id: <[email protected]> 
From: [email protected] 
Date: Tue, 20 Nov 2012 11:01:22 -0500 

烦人,我可以看到从通过正确的到来,但它就像收到与主机的信息覆盖。我在服务器级别丢失了什么?

我也尝试在php.ini文件(ini_set(sendmail_from,[email protected]);)中设置它,它没有区别。

TA

+0

相关:http://stackoverflow.com/questions/179014/how-to-change-envelope-从地址使用PHP的邮件http://stackoverflow.com/questions/2229435/how-do-i-set-the-from-address-in-a-php-contact-form – twodayslate

+0

我通常使用PHPMailer来从PHP脚本发送电子邮件,使用^^ – Naryl

回答

2

你可以尝试加入除了报头,如X-发件人:

$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"; 
+0

立即尝试。愚蠢的问题:是否有将$ $头分为不同行的原因?我问,因为我在邮件客户端读取'\ r \ n'的邮件客户端的成功率为50/50 – TH1981

+0

我认为邮件客户端解析邮件的方式确实有所不同,但我并不真诚地知道。这是php.net如何显示他们的示例代码。 –

+0

谢谢。添加额外的头文件已经工作了,尽管它仍然在头文件中的收到信息中显示了主机名,但它不会覆盖该头文件。 ta – TH1981