2012-01-02 227 views
3

我使用PHPmailer發送電子郵件。如何使用DKIM簽名向Phpmailer發送電子郵件?

我安裝了postfix服務和DKIM-Milter來生成密鑰。

它工作正常,如果我用它來發送的郵件的命令行和郵件與DKIM簽名顯示「簽署者:mydomain.com」

Authentication-Results: mx.google.com; spf=pass (google.com: domain of [email protected] designates 182.50.xxx.xxx as permitted sender) [email protected]; dkim=pass [email protected] 

DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mydomain.com; s=default; 
    t=1325531456; bh=+gZFhu4Id2AXb8UVbFLzDVVlChWGhvxvJUIdjdMLQsk=; 
    h=To:Subject:Message-Id:Date:From; 
    b=mH4GV8ayicc6UMn1uopCc9VJb5v2MiOKQpEtwJjckzoJ8ePhRKQIZI5KnzSdSoSP3 
    BtmehOQhMn9kIR/TlL2dlSog2EkRNeAaWcmO1K3khtCZ7rkXHGJsDn9C6l49K0tJa2 
    rplPOSI7wS8+3NCEiuc5sjZimPo4v9WuTECVqxkg= 

但我想使用的PHPMailer(5.1),以與DKIM簽名發送的郵件支持,但返回此:

Authentication-Results: mx.google.com; spf=pass (google.com: domain of [email protected] designates 182.50.xxx.xxx as permitted sender) [email protected]; dkim=neutral (bad format) [email protected] 

DKIM-Signature: v=1; a=rsa-sha1; q=dns/txt; l=70; s=default; 
    t=1325533594; c=relaxed/simple; 
    h=From:To:Subject; 
    d=mydomain.com; [email protected]; 
    z= 
    | 
    |Subject:=20Testing=20email=20from=20phpmailer; 
    bh=lC+16EvauA2HuJG03ArE6CtgLuY=; 
    b= 

我檢查了class.phpmailer.php文件,它具有一定的DKIM選項:

public $DKIM_selector = 'default'; 

    /** 
    * Used with DKIM DNS Resource Record 
    * optional, in format of email address '[email protected]' 
    * @var string 
    */ 
    public $DKIM_identity = ''; 

    /** 
    * Used with DKIM DNS Resource Record 
    * optional, in format of email address '[email protected]' 
    * @var string 
    */ 
    public $DKIM_domain  = ''; 

    /** 
    * Used with DKIM DNS Resource Record 
    * optional, in format of email address '[email protected]' 
    * @var string 
    */ 
    public $DKIM_private = ''; 

如何配置此選項?我知道公鑰和私鑰,但是什麼是$ DKIM_private和$ DKIM_identity?

+0

由於它們是可選的,你可能不需要它們? – Corubba 2012-01-03 01:11:57

+0

@BloodyWorld如果你想發送帶有DKIM簽名的郵件,它們是必備的。 – Angolao 2012-01-03 13:43:20

回答

9

$ DKIM_private是您的私鑰和$ DKIM_identity,以及我不確定,但它是可選的,您可以在這裏找到更多信息:http://dkim.org/specs/draft-allman-dkim-base-01.html#anchor9。這裏是一些示例代碼。

$mail->DKIM_domain = 'mydomain.com'; 
$mail->DKIM_private = '/path/to/private_key'; 
$mail->DKIM_selector = 'default'; //this effects what you put in your DNS record 
$mail->DKIM_passphrase = '1234567'; 

希望幫助

+2

'DKIM_private'是使用密鑰進行文件存儲的路徑,而不是密鑰字符串本身。 – Turako 2016-02-19 16:00:13

2

需要,打破了DKIM-Signature頭,使得出現在新行每個屬性。 DKIM的PHPMailer實現有一些必須糾正的問題。

$DKIM_identity值是可選的。要了解$DKIM_private的作用,請參閱DKIM_Sign方法。

0

從這裏開始

http://dkim.worxware.com/

在底部 - 點擊繼續....

它將alow你生成指令

簡言之公鑰/私鑰: - 設置使用私鑰/公鑰文件發送以在郵件頭中添加dkim頭 - 修改公鑰的DNS txt記錄

0

我發現最新版本使用sha256而不是sha1,因此現有的DKIM生成器(http://dkim.worxware.com/)不起作用,除非您進入class.phpmailer.php文件並編輯sha256的所有提及返回到sha1,這樣做可以解決問題驗證者不能使用sha256作爲公鑰(給出錯誤)

+0

雖然這個鏈接可能回答這個問題,但最好在這裏包含答案的重要部分,並提供供參考的鏈接。如果鏈接頁面更改,則僅鏈接答案可能會失效。 - [來自評論](/ review/low-quality-posts/11186309) – 2016-02-08 15:41:13

+0

@ Magicprog.fr,他確實包括了*他的*答案的基本部分解釋瞭如何解決它 - *不管它是否正確* - 也他發佈的鏈接不是回答問題,因爲這只是DKIM生成器的鏈接,所以IMO這是一個*嘗試*來回答,而不是一個鏈接專用的答案,謝謝 – 2016-02-09 03:14:21

相關問題