DKIM 未验证但 dns 记录匹配密钥

DKIM not verified but dns record match key

努力使 DKIM 正常工作。目前这是 mail-tster 结果。

https://www.mail-tester.com/test-38w40jo78

我主要缺少 DKIM 这里是我的 dns 记录。

 truebud.ca text = "truebud-64839v5873958h3ddrg._domainkey.truebud.ca k=rsa\; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQChKyCHHZEkrYfTdcB2VX0nKL8Vhicb+xQsNswOgo5+IK2ipg97VJb+lKAT+jHMXyk4KPTkUUI/8rwa2IfUKsr/BQXy6csNkmM0Y00H5/+QRAYn+ktoRWO1zXvO2sygzCELgGxcj5pHkOd4xLGhTnTpHh7UAjTp" "/swV5E18dpAubQIDAQAB"
 truebud.ca text = "v=DMARC1\; p=none"
 truebud.ca text = "v=spf1 a mx ip4:216.221.70.222 ~all"
 truebud.ca text = "_domainkey.truebud.ca o=~\; r=info@truebud.ca"

这是我的 phpmailer 代码

<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
//use PHPMailer\PHPMailer\Exception;

require 'vendor/phpmailer/src/Exception.php';
require 'vendor/phpmailer/src/PHPMailer.php';
require 'vendor/phpmailer/src/SMTP.php';

// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
$site = 'truebud.ca';
$sitename = 'Truebud';
try {
    //Server settings
    //$mail->isSMTP();                                            // Send using SMTP
    $mail->Host       = '216.221.70.222';                    // Set the SMTP server to send through
    $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
    $mail->Username   = 'info@'.$site;                     // SMTP username
    $mail->Password   = '[pass]';                               // SMTP password
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
    $mail->Port       = 587;                                    // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above

    //Recipients
    $mail->setFrom('info@'.$site,$sitename);
    $mail->addAddress('test-38w40jo78@srv1.mail-tester.com');
    $mail->addReplyTo('info@'.$site,$sitename);
    $mail->addCC('cc@'.$site);
    $mail->addBCC('bcc@'.$site);

    // Attachments
    //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
    //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name

    // Content
    $mail->isHTML(true);                                  // Set email format to HTML
    $mail->Subject = 'Truebud promotion';
    $mail->Body    = 'wall o' text';
    $mail->AltBody = 'wall 'o text';
    $mail->AddCustomHeader("List-Unsubscribe: <mailto:unsubscribe@".$site."?subject=Unsubscribe>,<http://".$site."/unsubscribe.php>");
    $mail->DKIM_domain = $site;
    $mail->DKIM_private = "rsa.private"; //path to file on the disk.
    $mail->DKIM_selector = $sitename."-64839v5873958h3ddrg";// change this to whatever you set during step 2
    $mail->DKIM_passphrase = "";
    $mail->DKIM_identity = $mail->From;

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}

我已经在这里待了一个星期了。我错过了什么?

他们的错误是:

We were not able to retrieve your public key. Please ensure that you inserted your DKIM TXT DNS record on your domain truebud.ca using the selector Truebud-64839v5873958h3ddrg.

我知道出了什么问题 — 您的 DKIM DNS 条目格式不正确。

# dig txt Truebud-64839v5873958h3ddrg._domainkey.truebud.ca
Truebud-64839v5873958h3ddrg._domainkey.truebud.ca. 120 IN TXT "truebud-64839v5873958h3ddrg._domainkey.truebud.ca v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQChKyCHHZEkrYfTdcB2VX0nKL8Vhicb+xQsNswOgo5+IK2ipg97VJb+lKAT+jHMXyk4KPTkUUI/8rwa2IfUKsr/BQXy6csNkmM0Y00H5/+QRAYn+ktoRWO1zXvO2sygzCELgGxcj5pHkOd4xLGhTnT" "pHh7UAjTp/swV5E18dpAubQIDAQAB"

您在记录值中得到了主机名 - 它应该以 v=DKIM1 开头,例如:

truebud.ca text = "v=DKIM1; k=rsa\; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQChKyCHHZEkrYfTdcB2VX0nKL8Vhicb+xQsNswOgo5+IK2ipg97VJb+lKAT+jHMXyk4KPTkUUI/8rwa2IfUKsr/BQXy6csNkmM0Y00H5/+QRAYn+ktoRWO1zXvO2sygzCELgGxcj5pHkOd4xLGhTnTpHh7UAjTp" "/swV5E18dpAubQIDAQAB"

不过,我在测试的时候看到你改了,所以我猜你也发现了同样的错误!