0

经过大量搜索并检查了很多教程和问答,我没有找到答案!

我在 Debian 上使用 virtualmin。我启用了 DKIM 并使用 PHPMailer:

    require("external/mail2/class.phpmailer.php");
    require("external/mail2/class.smtp.php");

    $mail= new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPAuth=true;

    $mail->Host = "mail.rexobit.com";
    $mail->Username= "my user name";
    $mail->Password= 'my password';
    $mail->AddAddress('myemail@gmail.com', '');
    $mail->SetFrom('notifications@rexobit.com', 'REXOBIT Notify');

    $mail->DKIM_domain = 'rexobit.com';
    $mail->DKIM_selector = '4040';
    $mail->Encoding = "base64";
    $mail->DKIM_private = '/etc/dkim.key';
    $mail->DKIM_passphrase = '';
    $mail->DKIM_identity = 'notifications@rexobit.com';

    $mail->Subject = 'testing smtp email';
    $mail->IsHTML(true);
    $mail->MsgHTML('this is a test email');
    $mail->AltBody= 'email test';
    if (!$mail->Send()) {
        echo 'Mailer Error: '. $mail->ErrorInfo;
    } else {
        echo 'Message sent!';
    }

gmail 上的结果:SPF:通过,IP 为 2a02:4780:8:6:2:2b... DKIM:'FAIL' with domain rexobit.com DMARC:'PASS'

当我在这样的代码上删除 DKIM 部分时:

    require("external/mail2/class.phpmailer.php");
    require("external/mail2/class.smtp.php");

    $mail= new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPAuth=true;

    $mail->Host = "mail.rexobit.com";
    $mail->Username= "my user name";
    $mail->Password= 'my password';
    $mail->AddAddress('myemail@gmail.com', '');
    $mail->SetFrom('notifications@rexobit.com', 'REXOBIT Notify');

    $mail->Subject = 'testing smtp email';
    $mail->IsHTML(true);
    $mail->MsgHTML('this is a test email');
    $mail->AltBody= 'email test';
    if (!$mail->Send()) {
        echo 'Mailer Error: '. $mail->ErrorInfo;
    } else {
        echo 'Message sent!';
    }

DKIM彻底消失了!没有签名:gmail的结果:SPF:通过IP 2a02:4780:8:6:2:2b ... DMARC:'PASS'

我使用了 2048 和 1024 键,结果相同。我也在 virtualmin 服务器上禁用了 DKIM:没有成功。DKIM 自动创建的 DNS。但我创建了一个密钥对,添加到 dns 并在 phpmailer 中使用它,但结果相同!

谷歌完整结果:

    Delivered-To: hamidvaghari@gmail.com
    Received: by 2002:a9d:5a8:0:0:0:0:0 with SMTP id 37csp6792321otd;
            Tue, 14 Jan 2020 23:49:08 -0800 (PST)
    X-Google-Smtp-Source: APXvYqyipy6njznZ0kMNV2V+cOd1k8Bp/bf3OF92K2umRR4xYOUBOU9NvfxRiW6oMAPH5Vb26Sxo
    X-Received: by 2002:a17:906:e86:: with SMTP id p6mr27208898ejf.299.1579074548335;
            Tue, 14 Jan 2020 23:49:08 -0800 (PST)
    ARC-Seal: i=1; a=rsa-sha256; t=1579074548; cv=none;
            d=google.com; s=arc-20160816;
            b=ni1Zo9tfatMw4rukiT6Kq/s08pOGgjgYU6/Q/+QlDISkUnkGYzvs7wtC4iFYZX01Nl
             qHWRLUfqExqx5oJN+2g1NvOUp+UhZk9HarE6v/Xy7qjADDbiTXvNIFRBhlR6nC9t2ADq
             DmLVEzmtxEjYrYxbncbt1cl4kGWlQfu3X5/wPo66Mh89p3gdMOUJWVQbRb/akaivhIK/
             ZQjirZ8MAVzTdtJ1AjDesUu5F4+xLi8H1B1Nb7bLOwS81W+lWUn8EQFOYz3eOo7LFOlX
             CCVciMJFompewrqRurRCVwh5b5WyGJReDCMElXoJcHIhRfW2Nt8/Uze3bWGe4Cnyz/y5
             ij3w==
    ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
            h=mime-version:message-id:reply-to:from:date:dkim-signature:subject
             :to;
            bh=/JG3Oa95UztnpL1MJZUL9Uqkjr7talhabzwuJCduqaw=;
            b=fSCo7HHsDKdSYxmlujr2tUGqbCx+08+dzrGTIEYUW/j5bABOzLjZSKP7jplZ4vzIv/
             KObFrCHjn4MhydtalG1+fQLRl0TzvMcIX+qAHHLuvlwTzhL3W15vHUdfsEOoI6cJJ30D
             /RQ2IL9JIvMbo2s2p2O5Fij3RnduqLc0NAywFKfxPaOaqSxQD67YsxDe2RN62z17w0dT
             J5EvjLXtBy+tmo6VW9l0MQiDWKN0vxi6MEJC8s3XVjgygJz1vcM5tPpR6ZH70usG7e15
             rLP8nJzP06XCzB8aWqRzIPdRHh4kGRIjpfsVvBoHy2TjKbHjSgmQ6VeanmgR6sqpQO4a
             fAfA==
    ARC-Authentication-Results: i=1; mx.google.com;
           dkim=neutral (bad format) header.i=@rexobit.com header.s=5050;
           spf=pass (google.com: domain of notifications@rexobit.com designates 2a02:4780:8:6:2:2b17:c6c2:18f5 as permitted sender) smtp.mailfrom=notifications@rexobit.com;
           dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rexobit.com
    Return-Path: <notifications@rexobit.com>
    Received: from vps.server.local ([2a02:4780:8:6:2:2b17:c6c2:18f5])
            by mx.google.com with ESMTPS id h22si12150651ejc.261.2020.01.14.23.49.08
            for <hamidvaghari@gmail.com>
            (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
            Tue, 14 Jan 2020 23:49:08 -0800 (PST)
    Received-SPF: pass (google.com: domain of notifications@rexobit.com designates 2a02:4780:8:6:2:2b17:c6c2:18f5 as permitted sender) client-ip=2a02:4780:8:6:2:2b17:c6c2:18f5;
    Authentication-Results: mx.google.com;
           dkim=neutral (bad format) header.i=@rexobit.com header.s=5050;
           spf=pass (google.com: domain of notifications@rexobit.com designates 2a02:4780:8:6:2:2b17:c6c2:18f5 as permitted sender) smtp.mailfrom=notifications@rexobit.com;
           dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rexobit.com
    Received: by vps.server.local (Postfix, from userid 1001) id F199223978; Wed, 15 Jan 2020 07:49:07 +0000 (UTC)
    To: hamidvaghari@gmail.com
    Subject: testing smtp email
    X-PHP-Originating-Script: 1001:class.phpmailer.php
    X-PHPMAILER-DKIM: phpmailer.worxware.com
    DKIM-Signature: v=1; a=rsa-sha1; q=dns/txt; l=340; s=5050; t=1579074547; c=relaxed/simple; h=From:To:Subject; d=rexobit.com; i=notifications@rexobit.com; z= | |Subject:=20testing=20smtp=20email; bh=R/emTcIGHSLVMGRNT6rmQdfikuw=; b=
    Date: Wed, 15 Jan 2020 07:49:07 +0000
    From: REXOBIT Notify <notifications@rexobit.com>
    Reply-to: REXOBIT Notify <notifications@rexobit.com>
    Message-ID: <933a2cee08fd835247b62fbddb5d763a@rexobit.com>
    X-Priority: 3
    X-Mailer: PHPMailer 5.1 (phpmailer.sourceforge.net)
    MIME-Version: 1.0
    Content-Type: multipart/alternative; boundary="b1_933a2cee08fd835247b62fbddb5d763a"

    --b1_933a2cee08fd835247b62fbddb5d763a
    Content-Type: text/plain; charset = "utf-8"
    Content-Transfer-Encoding: base64

    ZW1haWwgdGVzdA==
    --b1_933a2cee08fd835247b62fbddb5d763a
    Content-Type: text/html; charset = "utf-8"
    Content-Transfer-Encoding: base64

    dGhpcyBpcyBhIHRlc3QgZW1haWw=
    --b1_933a2cee08fd835247b62fbddb5d763a--

有什么帮助吗?

4

3 回答 3

0

SetFrom理论上也默认设置了 Sender 参数。但是,我有时会明确设置两者以保证标头输出的内容,这有时会帮助我解决 DKIM 问题。

$phpmailer->Sender='noreply@mydomain.com';
$phpmailer->SetFrom('noreply@mydomain.com', 'My Name', FALSE);
于 2022-02-01T11:01:29.727 回答
0

除了实现 domainkey 之外,您的邮件服务器可能还需要配置;根据我在 Debian 上的经验,例如 exim / exim4 需要显式设置才能生成 DKIM(包括让它知道要验证消息的哪些部分)。

于 2022-01-06T02:09:14.257 回答
0

我认为问题在于您的 DKIM 密钥的 DNS 条目。请看下面的测试:

SPF check
1 SPF record found for the domain rexobit.com :

"v=spf1 a mx a:rexobit.com ip4:194.5.159.246 ~all"

DKIM check
No DNS record found for 4040._domainkey.rexobit.com

你需要有一个像4040._domainkey IN TXT "v=DKIM1; k=rsa; t=s; p=value_of_the_dkim_public_key"

更新域的 DNS 文件后,您应该等待更改传播,然后重试。

或使用任何在线 DKIM 域检查器,看看它是否有效

于 2020-01-23T08:12:30.440 回答