【问题标题】:Use dkim in phpmailer code with privacy key在带有隐私密钥的 phpmailer 代码中使用 dkim
【发布时间】:2014-09-05 07:13:09
【问题描述】:

我正在使用 PHPMailer。

我在发送文件时添加了 DKIM 属性。

代码如下:

// $mail is PHPMailer class
$mail->SMTPAuth = true; 
$mail->SMTPSecure = "ssl";
$mail->Host = "*******"; 
$mail->Port  = ***; 
$mail->Mailer= "SMTP";
//...
$mail->DKIM_domain = 'mydomain.com';
$mail->DKIM_identity = '@mydomain.com';

$mail->DKIM_private =  __DIR__ . '/privacy_key_mydomain.txt';
$mail->DKIM_selector = 'default';
$mail->DKIM_passphrase = ''; // only ssl.
//...

(与Send mail in phpmailer using DKIM Keys 上的示例相同)

发送到电子邮件时,例如我的(gmail),我没有问题,我看到我的电子邮件是由 mydomain.com 签名的。

我还看到,在发送 DKIM 签名的电子邮件源中。

尽管如此,我发送电子邮件的一些客户拒绝了我的电子邮件,并带有以下消息(尤其是对于 yahoo 电子邮件 - 超过 90% 的拒绝者使用 yahoo 发送电子邮件)。

554 消息不允许 - 标头不符合 RFC[291]

当我做了一些解决方法时,我发现此邮件被检测为垃圾邮件。

我在我的网站上使用 CPANEL,它有圆形立方体 - 所以我在圆形立方体上测试它(用圆形立方体向客户发送消息) - 似乎没问题。没有垃圾邮件检测。

所以,我怀疑隐私密钥文件可能不正确(我有一个 SSL 站点 - 所以我使用与我自己的站点相同的隐私密钥)。

可能有什么问题?我应该检查什么以避免我的电子邮件被检测为垃圾邮件?

这是邮件源结果:

Delivered-To: myaccount@gmail.com
Received: by 10.114.75.12 with SMTP id y12csp118366ldv;
        Tue, 15 Jul 2014 11:44:11 -0700 (PDT)
X-Received: by 10.140.104.49 with SMTP id z46mr36090427qge.74.1405449850437;
        Tue, 15 Jul 2014 11:44:10 -0700 (PDT)
Return-Path: <support@mydomain.com>
Received: from lin9.maindomain10.net (lin9.maindomain10.net. [1.2.3.4])
        by mx.google.com with ESMTPS id t14si21957304qac.66.2014.07.15.11.44.09
        for <myaccount@gmail.com>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Tue, 15 Jul 2014 11:44:10 -0700 (PDT)
Received-SPF: pass (google.com: domain of support@mydomain.com designates 1.2.3.4 as permitted sender) client-ip=1.2.3.4;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of support@mydomain.com designates 1.2.3.4 as permitted sender) smtp.mail=support@mydomain.com;
       dkim=pass header.i=@mydomain.com
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mydomain.com; s=default;
    h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Subject:Reply-To:From:To:Date:Subject:To; bh=HBLjhR1eb0w5FQ9aVj60Gu0x3jP9XWQ7LQkpzTRHjfQ=;
    b=ECWMCs3iPsjuvlT473K9u3skwyNRVunmnv3p440Nk2ZJVrbuWoO0vgzaWM8gjCC503ADKivdfrrOek8TgTSEI7G4B3WMCHI50PWq68W5rcscYJqErWxuqAVcSl4r5tomk88AYPhHiotCugmRTjwQ2K/JBtHsAvMhTlVQMMXsMl0=;
Received: from mainuser by lin9.maindomain10.net with local (Exim 4.82)
    (envelope-from <support@mydomain.com>)
    id 1X77hp-0001f9-SH; Tue, 15 Jul 2014 14:44:01 -0400
To: myName Mizrahi <myaccount@gmail.com>
Subject: Statistics from Sample Name site
Date: Tue, 15 Jul 2014 14:44:01 -0400
To: myName Mizrahi <myaccount@gmail.com>
From: "donotreply@mydomain.com" <root@localhost>
Reply-To: Sample Name site <donotreply@mydomain.com>
Subject: Statistics from Sample Name site
Message-ID: <d984a2c6308ef2a97cf6ccfe6292263a@mydomain.com>
X-Priority: 3
X-Mailer: PHPMailer 5.2.4 (http://code.google.com/a/apache-extras.org/p/phpmailer/)
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset=UTF-8
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - lin9.maindomain10.net
X-AntiAbuse: Original Domain - gmail.com
X-AntiAbuse: Originator/Caller UID/GID - [927 895] / [47 12]
X-AntiAbuse: Sender Address Domain - mydomain.com
X-Get-Message-Sender-Via: lin9.maindomain10.net: authenticated_id: mainuser/sender_address_domain 

从圆形立方体发送消息时,电子邮件来源如下所示:

Delivered-To: myaccount@gmail.com
Received: by 10.114.75.12 with SMTP id y12csp118605ldv;
        Tue, 15 Jul 2014 11:48:53 -0700 (PDT)
X-Received: by 10.224.161.129 with SMTP id r1mr34110372qax.86.1405450132678;
        Tue, 15 Jul 2014 11:48:52 -0700 (PDT)
Return-Path: <support@mydomain.com>
Received: from lin9.maindomain10.net (lin9.maindomain10.net. [1.2.3.4])
        by mx.google.com with ESMTPS id x8si13226659qas.81.2014.07.15.11.48.52
        for <myaccount@gmail.com>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Tue, 15 Jul 2014 11:48:52 -0700 (PDT)
Received-SPF: pass (google.com: domain of support@mydomain.com designates 1.2.3.4 as permitted sender) client-ip=1.2.3.4;
Authentication-Results: mx.google.com;
       spf=pass (google.com: domain of support@mydomain.com designates 1.2.3.4 as permitted sender) smtp.mail=support@mydomain.com;
       dkim=pass header.i=@mydomain.com
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mydomain.com; s=default;
    h=Message-ID:Subject:To:From:Date:Content-Transfer-Encoding:Content-Type:MIME-Version; bh=Bynm51C7RZD/vZ81iEMKjxxLoAJtSmKFcwU/eyFzPs8=;
    b=fUX+UKS9Ua0HK35AOBRBJbmqTEuKscCYAsPyxs3If3dhhvb/AvAjl1gR9Rz9AN0EX0mu275wtaN5Y1JWP+8w8VcGebJ9FEWsltCl9nwqL6bos/eEqJxTWjDG6ch9MHo3G0mSE326Pyc13JWa59InSgJyWi8MSstT1POfuEhfe28=;
Received: from localhost.localdomain ([127.0.0.1]:54911 helo=mydomain.com)
    by lin9.maindomain10.net with esmtpa (Exim 4.82)
    (envelope-from <support@mydomain.com>)
    id 1X77mO-0001l7-1O
    for myaccount@gmail.com; Tue, 15 Jul 2014 14:48:44 -0400
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8;
 format=flowed
Content-Transfer-Encoding: 7bit
Date: Tue, 15 Jul 2014 14:48:43 -0400
From: support@mydomain.com
To: myaccount@gmail.com
Subject: test
Message-ID: <ed6307c2c9504e8ba9ec21f073d5f863@mydomain.com>
X-Sender: support@mydomain.com
User-Agent: Roundcube Webmail/0.9.5
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - lin9.maindomain10.net
X-AntiAbuse: Original Domain - gmail.com
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - mydomain.com
X-Get-Message-Sender-Via: lin9.maindomain10.net: authenticated_id: support@mydomain.com                                                                                                                                                                                                                                                                   

Round-Cube 可以在没有垃圾邮件的情况下使用。 造成问题的主要区别是什么?

谢谢:)

【问题讨论】:

  • 你能发布一个带有标题的示例消息吗?如果您的私钥错误,它根本不会签名,并且在 google 上的验证将失败。
  • 隐私包括“公钥”和“私钥”一起(0A 仅作为新行的十六进制)。
  • 这就是客户作为 dkim-signature 得到的(还有什么?:DKIM-Signature: v=1; a=rsa-sha1; q=dns/txt; l=309; s=default; t=1405409881;c=轻松/简单;h=From:To:Subject;d=mydomain.com;i=@mydomain.com;z=From:=20"donotreply@lmydomain.com"=20 |到:= 20my20full20name |主题:= 20test; BH = TsgRTSRyuHuPbbEhcGc2AZBcWYI =; b = QffG / IucUDzMEjbOZ05pOJ0SEx7KJ + bCk58hc7cSMmsrYpV7ChIZl2VA0ZfVxEtDMthLjgJvEmThnhiPGsQdKU8UWWaSEIisGLTZ / 9lAom4mSvTfuQ7hc4IhfgBHZg6MU1gOP2XbHRgtWgUvU0Vkb6PAMjAB 跨度>
  • 您的私钥不应包含在您的消息中的任何位置。请在问题中发布整个消息标题 - 评论格式不适合显示这样的代码块。
  • 我不明白 - 带有标题的消息是什么意思?源代码大约有 50 行。

标签: phpmailer dkim


【解决方案1】:

5.2.4 相当老旧且有缺陷 - 您需要更新到 latest PHPMailer from GitHub

【讨论】:

    猜你喜欢
    • 2014-08-19
    • 1970-01-01
    • 2014-09-27
    • 2013-04-06
    • 2012-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-24
    相关资源
    最近更新 更多