【问题标题】:Gmail uses original "TO" address instead of "FROM" address for replyGmail 使用原始“TO”地址而不是“FROM”地址进行回复
【发布时间】:2012-10-21 01:27:46
【问题描述】:

使用CI's email library,我有以下代码向用户发送密码:

$email_html_message         =   '<html><body>'.
                                        'Your password is '.$password.'<br>'.
                                        '<a href="'.  base_url().'">Login to MySite</a>'.
                                        '</body></html>';


        $config['charset']  =   'iso-8859-1';
        $config['mailtype'] =   'html';
        $this->email->initialize($config);

        $this->email->from('ray@MySite.com', 'MySite Admin');
        $this->email->to($user_email);
        $this->email->subject('Your MySite Login');
        $this->email->message($email_html_message);
        $this->email->send();

我在两个帐户上测试了此代码:Gmail 和我的 ISP 的 smtp 电子邮件帐户。

两个测试都发送了一封电子邮件,但问题是:

如果我点击通过 gmail 回复,回复地址是电子邮件发送到的地址:

当我通过 Windows Mail(例如我的 smtp 帐户)单击回复时,不会发生这种情况。

这是带有来自 gmail 标头的“原始消息”:

Delivered-To: ray023@gmail.com
Received: by 10.114.17.8 with SMTP id k8csp412473ldd;
        Wed, 31 Oct 2012 07:27:06 -0700 (PDT)
Received: by 10.220.142.79 with SMTP id p15mr18061226vcu.71.1351693626443;
        Wed, 31 Oct 2012 07:27:06 -0700 (PDT)
Return-Path: <bounce-cgi-moo.ray023@yourhostingaccount.com>
Received: from mailout12.yourhostingaccount.com (mailout12.yourhostingaccount.com. [65.254.253.98])
        by mx.google.com with ESMTP id p5si2963631vcv.55.2012.10.31.07.27.05;
        Wed, 31 Oct 2012 07:27:05 -0700 (PDT)
Received-SPF: pass (google.com: domain of bounce-cgi-moo.ray023@yourhostingaccount.com designates 65.254.253.98 as permitted sender) client-ip=65.254.253.98;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of bounce-cgi-moo.ray023@yourhostingaccount.com designates 65.254.253.98 as permitted sender) smtp.mail=bounce-cgi-moo.ray023@yourhostingaccount.com
Received: from mailscan13.yourhostingaccount.com ([10.1.15.13] helo=mailscan13.yourhostingaccount.com)
    by mailout12.yourhostingaccount.com with esmtp (Exim)
    id 1TTZG5-0005Lf-Dt
    for ray023@gmail.com; Wed, 31 Oct 2012 10:27:05 -0400
Received: from impout01.yourhostingaccount.com ([10.1.55.1] helo=impout01.yourhostingaccount.com)
    by mailscan13.yourhostingaccount.com with esmtp (Exim)
    id 1TTZG2-0007KY-GM
    for ray023@gmail.com; Wed, 31 Oct 2012 10:27:02 -0400
Received: from cgi1703.yourhostingaccount.com ([10.1.12.150])
    by impout01.yourhostingaccount.com with NO UCE
    id HqT21k00s3EEVBe01qT2XN; Wed, 31 Oct 2012 10:27:02 -0400
X-Authority-Analysis: v=2.0 cv=IICA+3TG c=1 sm=1 a=0bVzInp0yugA:10
 a=UT1nndvi2uwA:10 a=e1QP36Bl1McA:10 a=Gm7PUgscJ9MA:10 a=jPJDawAOAc8A:10
 a=mM4-eZ0ns8IA:10 a=PgEUWBzPAAAA:8 a=2RTERvT5bsMA:10 a=t2MNXjrCa7SdDSCJ3MYA:9
 a=wPNLvfGTeEIA:10 a=_W_S_7VecoQA:10 a=MvC2+Uy32Q89d9+Fzzoamg==:117
X-EN-OrigOutIP: 10.1.12.150
X-EN-IMPSID: HqT21k00s3EEVBe01qT2XN
Received: from moo.ray023 by cgi1703.yourhostingaccount.com with local (Exim)
    id 1TTZFR-0003Hw-20
    for ray023@gmail.com; Wed, 31 Oct 2012 10:26:25 -0400
X-EN-Info: U=moo.ray023 P=/index.php
X-EN-CGIUser: moo.ray023
X-EN-CGIPath: /index.php
X-EN-OrigIP: 173.191.128.136
To: ray023@gmail.com
Subject: =?iso-8859-1?Q?Your_MySite_Login?=
X-PHP-Originating-Script: 3651509:Email.php
User-Agent: CodeIgniter
Date: Wed, 31 Oct 2012 10:26:24 -0400
From: "MySite Admin" <ray@MySite.com>
Reply-To: "ray@MySite.com" <ray@MySite.com>
X-Sender: ray@MySite.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <5091351101295@MySite.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_50913511012dd"
X-EN-Timestamp: Wed, 31 Oct 2012 10:26:25 -0400
Sender:  "MySite Admin" <ray@MySite.com>

This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_50913511012dd
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Your password is Login to MySite


--B_ALT_50913511012dd
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

<html><body>Your password is <br><a href=3D"http://MySite.com/">Logi=
n to MySite</a></body></html>

--B_ALT_50913511012dd--

知道如何用 gmail 解决这个问题吗?

【问题讨论】:

  • 所有标题看起来都已正确设置,Gmail 没有理由使用该地址进行回复。其他地址是否也经常发生这种情况?另外,不要通过电子邮件发送明文密码。这是非常糟糕的安全做法。
  • @Sammitch 我在网站上只有两个“用户”,他们都是我。我了解 pw 的安全问题,但要一步一步来。如果超出单个用户,我将编写更安全的密码重置代码。
  • 据我所知,这是由 Google 强制执行的,以防止滥用。换句话说,你不能改变它。
  • @repox 这是一种特殊的安全措施。 Gmail 团队:“我们将允许这些类型的电子邮件显示在收件箱中(不是垃圾邮件),并允许用户查看回复地址;但是,为了防止滥用,当他们点击回复时,它会显示用户的拥有自己的 Gmail 帐户。”
  • @ray023 尝试谷歌搜索 Return-Path 和 From 标头之间的区别。

标签: php codeigniter email gmail


【解决方案1】:

在测试了一个 Yahoo 邮件帐户和一个单独的 Gmail 帐户(两者都可以正常工作)后,我发现问题只出在我的 gmail 帐户上。

经过一番搜索,我找到了一个good question on SO,它指向了我to this article(特别注以粗体):

我在发送的 PHP 联系表单中遇到了同样的问题 邮件到我的 Gmail 帐户。如果“发件人”地址与 “收件人”地址,或在 GMail 设置中配置为 “发送为...”帐户,Gmail 回复“收件人”地址而不是 “回复”地址。 一个简单的解决方法是指定非 Gmail “发件人”地址。现在它可以工作了,Gmail 正确地尊重 “回复”地址。毫无疑问,这是一个 Gmail 中的错误。

粗体部分是我的 Gmail 的设置方式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-23
    • 2011-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-12
    相关资源
    最近更新 更多