简体   繁体   English

使用 DKIM 密钥在 phpmailer 中发送邮件

[英]Send mail in phpmailer using DKIM Keys

Currents i am using phpmailer to send mail's. Currents 我正在使用 phpmailer 发送邮件。 now how its possible to send email in phpmailer with DKIM keys现在如何使用 DKIM 密钥在 phpmailer 中发送电子邮件

i search in phpmailer Class file and i found the below code我在 phpmailer 类文件中搜索,我找到了下面的代码

    /**
     * DKIM selector.
     * @type string
     */
    public $DKIM_selector = '';

    /**
     * DKIM Identity.
     * Usually the email address used as the source of the email
     * @type string
     */
    public $DKIM_identity = '';

    /**
     * DKIM passphrase.
     * Used if your key is encrypted.
     * @type string
     */
    public $DKIM_passphrase = '';

    /**
     * DKIM signing domain name.
     * @example 'example.com'
     * @type string
     */
    public $DKIM_domain = '';

    /**
     * DKIM private key file path.
     * @type string
     */
    public $DKIM_private = '';

Can i know how its possible.我能知道它是如何可能的吗?

If you take a look in the PHPMailer unit tests , there is an example of how to set up DKIM.如果您查看PHPMailer 单元测试,有一个关于如何设置 DKIM 的示例。

Here are the basics beyond what you already need to do to send a message (obviously change the domain, key path and selector to match your config, and add a passphrase if you use one);以下是发送消息所需的基础知识(显然,更改域、密钥路径和选择器以匹配您的配置,并在使用密码时添加密码); this also assumes that you are intending to sign using the same identifier as your From address:这还假设您打算使用与您的From地址相同的标识符进行签名:

$mail->DKIM_domain = 'example.com';
$mail->DKIM_private = '/path/to/my/private.key';
$mail->DKIM_selector = 'phpmailer';
$mail->DKIM_passphrase = '';
$mail->DKIM_identity = $mail->From;

When you send() the message (and not before), it will use these settings to generate a DKIM signature.当您send()消息时(而不是之前),它将使用这些设置来生成 DKIM 签名。

I have the following experience:我有以下经验:

  1. The pair of the keys generated at http://dkim.worxware.com/createkeys.php is probably intended for the SHA1, while the latest version 5.2.14 of the class.phpmailer.php is intended for SHA256.http://dkim.worxware.com/createkeys.php上生成的一对密钥可能适用于 SHA1,而class.phpmailer.php的最新版本 5.2.14 适用于 SHA256。
    The example above was not functional.上面的例子不起作用。
  2. I changed all settings and functions in the class.phpmailer.php from SHA256 on SHA1 (I replaced simply all strings SHA256 with the strings SHA1).我在 SHA1 上从 SHA256 更改了class.phpmailer.php中的所有设置和功能(我将所有字符串 SHA256 替换为字符串 SHA1)。
    My PHP script for DKIM signature has became functional.我的用于 DKIM 签名的 PHP 脚本已经可以运行了。

Start here 从这里开始

http://dkim.worxware.com/ http://dkim.worxware.com/

At the bottom - click Continue....this will take you to the tool to generate the private key, public key and how to use them 在底部 - 单击继续....这将带您到工具生成私钥,公钥以及如何使用它们

It will alow you to generate private/public key with instructions 它将使您生成带有指令的私钥/公钥

In brief: - seup to send using the private/public key file to add dkim headers in email header - modify DNS txt record for the public key 简而言之: - 使用私钥/公钥文件发送seup以在电子邮件头中添加dkim头 - 修改公钥的DNS txt记录

There are NO tutorials as of today's date - I FOUND it this after gettin g nowhere for a couple months 截至今天的日期没有任何教程 - 我发现它几个月之后无处可去

HTH HTH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM