title: SPF and DMARC PASS but DKIM 'FAIL' with domain XXX?
body: <p>After searching a lot and checking lots of tutorials and q&amp;a, I didn't find the answer!</p>
  
  <p>I'm using virtualmin on Debian. I enabled DKIM and use PHPMailer:</p>
  
  <pre><code>    require("external/mail2/class.phpmailer.php");
      require("external/mail2/class.smtp.php");
  
      $mail= new PHPMailer();
      $mail-&gt;IsSMTP();
      $mail-&gt;SMTPAuth=true;
  
      $mail-&gt;Host = "mail.rexobit.com";
      $mail-&gt;Username= "my user name";
      $mail-&gt;Password= 'my password';
      $mail-&gt;AddAddress('myemail@gmail.com', '');
      $mail-&gt;SetFrom('notifications@rexobit.com', 'REXOBIT Notify');
  
      $mail-&gt;DKIM_domain = 'rexobit.com';
      $mail-&gt;DKIM_selector = '4040';
      $mail-&gt;Encoding = "base64";
      $mail-&gt;DKIM_private = '/etc/dkim.key';
      $mail-&gt;DKIM_passphrase = '';
      $mail-&gt;DKIM_identity = 'notifications@rexobit.com';
  
      $mail-&gt;Subject = 'testing smtp email';
      $mail-&gt;IsHTML(true);
      $mail-&gt;MsgHTML('this is a test email');
      $mail-&gt;AltBody= 'email test';
      if (!$mail-&gt;Send()) {
          echo 'Mailer Error: '. $mail-&gt;ErrorInfo;
      } else {
          echo 'Message sent!';
      }
  </code></pre>
  
  <p>result on gmail :
          SPF:    PASS with IP 2a02:4780:8:6:2:2b...
          DKIM:   'FAIL' with domain rexobit.com
          DMARC:  'PASS' </p>
  
  <p>When I remove DKIM part on code like this :</p>
  
  <pre><code>    require("external/mail2/class.phpmailer.php");
      require("external/mail2/class.smtp.php");
  
      $mail= new PHPMailer();
      $mail-&gt;IsSMTP();
      $mail-&gt;SMTPAuth=true;
  
      $mail-&gt;Host = "mail.rexobit.com";
      $mail-&gt;Username= "my user name";
      $mail-&gt;Password= 'my password';
      $mail-&gt;AddAddress('myemail@gmail.com', '');
      $mail-&gt;SetFrom('notifications@rexobit.com', 'REXOBIT Notify');
  
      $mail-&gt;Subject = 'testing smtp email';
      $mail-&gt;IsHTML(true);
      $mail-&gt;MsgHTML('this is a test email');
      $mail-&gt;AltBody= 'email test';
      if (!$mail-&gt;Send()) {
          echo 'Mailer Error: '. $mail-&gt;ErrorInfo;
      } else {
          echo 'Message sent!';
      }
  </code></pre>
  
  <p>DKIM disappeared completely! no signing :
  result on gmail :
          SPF:    PASS with IP 2a02:4780:8:6:2:2b...
          DMARC:  'PASS' </p>
  
  <p>I used 2048 and 1024 keys, both same result. also I disabled DKIM on virtualmin server: no success.
  DNS created by DKIM automatically. but I created a key pair, added to dns and use it in phpmailer but same results!</p>
  
  <p>google complete result :</p>
  
  <pre><code>    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: &lt;notifications@rexobit.com&gt;
      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 &lt;hamidvaghari@gmail.com&gt;
              (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 &lt;notifications@rexobit.com&gt;
      Reply-to: REXOBIT Notify &lt;notifications@rexobit.com&gt;
      Message-ID: &lt;933a2cee08fd835247b62fbddb5d763a@rexobit.com&gt;
      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--
  </code></pre>
  
  <p>any help plz?</p>