1

我知道我在这里做一些愚蠢的事情,但我无法弄清楚。我正在使用以下内容发送电子邮件:

    $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

4

1 回答 1

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"; 
于 2012-11-20T16:15:47.893 回答