首页 > 解决方案 > DKMI 使用 phpmailer 无效

问题描述

我正在使用 php mailer 从我的办公室邮件地址发送邮件。当我发送消息时,DKIM 签名无效。


try {
    //Server settings
    $mail->SMTPDebug = SMTP::DEBUG_SERVER;                      // Enable verbose debug output
    $mail->isSMTP();                                            // Send using SMTP
    $mail->Host       = MAIL_HOST;                    // Set the SMTP server to send through
    $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
    $mail->Username   = MAIL_USER;                     // SMTP username
    $mail->Password   = MAIL_PASSWORD;                               // SMTP password
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted
    $mail->Port       = MAIL_PORT;                                    // TCP port to connect to
    $mail -> charSet = "UTF-8";

    //Recipients
    $mail->setFrom(MAIL_USER);
    $mail->addAddress('test-xxxxx@srv1.mail-tester.com', 'test-xxxx@srv1.mail-tester.com');     // Add a recipient

    // 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 = 'subject';
    
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    $mail->Body    = "My Content";

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

该消息将发送而没有任何错误,但我的 DKIM 无效。我无法创建新的 dkmi 私钥,因为我的办公室不允许我创建它。

为什么来自 mail Outlook 或 Outlook Web 邮件程序的邮件具有有效的 dkmi 签名?我正在使用微软的 office365 来发送我的邮件。

我该如何解决这个问题?

标签: phpphpmailer

解决方案


推荐阅读