如何将 "reply-to" 添加到我们从我们的网站收到的电子邮件 PHP 表格中?

How can "reply-to" be added to the email we get from our website PHP form?

更严格的 DMARC 政策意味着如果客户使用我们的在线表格输入雅虎或 AOL 电子邮件地址,我们将不会收到他们的电子邮件。

我认为这是因为 PHP 表单生成了一封从我们的网站服务器发送的电子邮件,但其中包含客户自己的电子邮件地址 'from'。当此 'from' 电子邮件是雅虎电子邮件时,它会触发我们的接收电子邮件帐户阻止它。 (我们使用 gmail 阅读和回复电子邮件。)

因此,我正在尝试研究如何修改 PHP 表单,将客户电子邮件地址设为 'reply-to' 并将我们自己的服务器电子邮件地址设为 'from'我们服务器上的 PHP 表单发送给我们。我希望能够在 gmail 中单击 'reply' 并能够直接向客户发送电子邮件。

在主题或 gmail 发件人字段中包含客户姓名也很好,这样可以使我们从表单收到的电子邮件更具可读性,但这无关紧要。

这是 php 文件的当前内容。

<?php
$to         ="info@futonz.co.nz";
$name       = ($_POST['name']);
$email      = ($_POST['email']);
$phone      = ($_POST['phone']);
$enquiry    = ($_POST['enquiry']);
$where      = ($_POST['where']);
$sub        = "Enquiry from the Futonz Website!";
$headers .= "From: $name <$email>\n";  
$headers .= "Content-Type: text/plain; charset=iso-8859-1\n";
$mes       = "".$sub."

Name: ".$name."
Email: ".$email."
Phone: ".$phone." 

Message: ".$enquiry."

I found Futonz by: ".$where."";

if(empty($name) || empty($email)) {
    header("Location:required-fields.html");
} 

elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
    header("Location:invalid-email.html");
}

else {
    mail($to, $sub, $mes, $headers);
    header("Location:contact-thanks.html");
    exit();
}
?>

阅读其他人的建议,我尝试将第一个 $headers 替换为以下内容:

$headers = 'From: '.futonz@futonz.co.nz."\r\n" .
        'Reply-To: '.$email."\r\n";

这没有用。浏览器进入空白屏幕。

我也试过在第一行下面添加另一个 $headers 行,如下所示:

$headers .= "From: $name <info@futonz.co.nz>\n";
$headers .= "Reply-to: $name <$email>\n";  

这确实在 gmail 中显示为客户的电子邮件为 'reply to'。但是,当在 Gmail 中单击 'reply' 时,它会将 info@futonz.co.nz 作为收件人!

在下方回复TheGreenKey的评论,使用代码时:

$headers .= "From: $name <info@futonz.co.nz>\n";
$headers .= "Reply-to: $name <$email>\n";  

则结果如下:

Delivered-To: info@futonz.co.nz
Received: by 10.52.238.130 with SMTP id vk2csp258969vdc;
        Fri, 13 Feb 2015 18:18:11 -0800 (PST)
X-Received: by 10.140.19.14 with SMTP id 14mr30541534qgg.37.1423880290937;
        Fri, 13 Feb 2015 18:18:10 -0800 (PST)
Return-Path: <futonz@futonz.co.nz>
Received: from zeke.hosts.net.nz (zeke.hosts.net.nz. [210.48.108.243])
        by mx.google.com with ESMTPS id q137si1269163qha.85.2015.02.13.18.18.09
        for <info@futonz.co.nz>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Fri, 13 Feb 2015 18:18:10 -0800 (PST)
Received-SPF: none (google.com: futonz@futonz.co.nz does not designate permitted sender hosts) client-ip=210.48.108.243;
Authentication-Results: mx.google.com;
       spf=none (google.com: futonz@futonz.co.nz does not designate permitted sender hosts) smtp.mail=futonz@futonz.co.nz
Received: from futonz.co.nz (localhost.localdomain [127.0.0.1])
    by zeke.hosts.net.nz (8.13.8/8.13.8) with ESMTP id t1E2Hxjm006900
    for <info@futonz.co.nz>; Sat, 14 Feb 2015 15:17:59 +1300
Received: (from futonz@localhost)
    by futonz.co.nz (8.13.8/8.13.8/Submit) id t1E2Hwf6006899;
    Sat, 14 Feb 2015 15:17:58 +1300
Date: Sat, 14 Feb 2015 15:17:58 +1300
Message-Id: <201502140217.t1E2Hwf6006899@futonz.co.nz>
To: info@futonz.co.nz
Subject: Enquiry from the Futonz Website!
From: Robin test <info@futonz.co.nz>
Reply-to: Robin test <teahigh@gmail.com>
Content-Type: text/plain; charset=iso-8859-1


Enquiry from the Futonz Website!

Name: Robin test
Email: teahigh@gmail.com
Phone: 09 

Message: 

I found Futonz by: 

请告诉我如何修改 php 表单,以便在 gmail 中单击 'reply' 时显示客户的电子邮件地址。

$headers = "From: " . strip_tags($_POST['email']) . "\r\n";
$headers .= "Reply-To: info@youradmin.com\r\n";
$headers .= "CC: info@youradmin.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

这是我用来修复 DMARC 身份验证问题 gmail 中出现的正确 'reply to' 电子邮件地址的代码。

<?php
$to       = "info@futonz.co.nz";
$name     = ($_POST['name']);
$email    = ($_POST['email']);
$phone    = ($_POST['phone']);
$enquiry  = ($_POST['enquiry']);
$where    = ($_POST['where']);
$sub      = "".$name."'s enquiry from the Futonz Website!";

$headers .= "MIME-Version:1.0\n";
$headers .= "Content-type: text/plain; charset=utf-8\n";
$headers .= "X-Mailer: $DOMAIN\n";
$headers .= "X-MSMail-Priority: normal\n";
$headers .= "Return-Path: ".$email."\r\n";
$headers .= "From: ".$from."\r\n";
$headers .= "Reply-To: ".$email."\r\n";

$mes      = "".$sub."\r\n\n";
$mes     .= "Name: ".$name."\r\n";
$mes     .= "Email: ".$email."\r\n";
$mes     .= "Phone: ".$phone."\r\n\n";
$mes     .= "Message: ".$enquiry."\r\n\n";
$mes     .= "I found Futonz by: ".$where."";

if(empty($name) || empty($email)) {
    header("Location:required-fields.html");
} 

elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
    header("Location:invalid-email.html");
}

else {
    mail($to, $sub, $mes, $headers);
    header("Location:contact-thanks.html");
    exit();
}
?>

感谢那些试图在这里提供帮助的人:)

尝试修复 yahoo DMARC 问题的人可能会对这个 link 感兴趣: https://help.yahoo.com/kb/mail/SLN24016.html