Skip to main content
New SPF lookups must resolve in milliseconds — why a DMARC tool's add-on isn't enough Learn Why → →
Advanced

How to Fix DKIM Authentication Failures in Qmail Servers

Brad Slavin
Brad Slavin General Manager

Quick Answer

How to fix DKIM authentication failures in Qmail servers by identifying common configuration errors, verifying DNS records, correcting key mismatches, and ensuring proper email signing to improve email deliverability and prevent spoofing.

Try Our Free DKIM Lookup

Auto-discover DKIM selectors for any domain.

Discover DKIM Selectors →
DKIM Authentication Failures

To troubleshoot DKIM failures in qmail, verify the DNS public key, selector, signing path, private key permissions, header integrity, relay behavior, and final signature verification result from the received message source.

Fast DKIM Qmail Troubleshooting Map

DKIM, short for DomainKeys Identified Mail, lets receiving systems verify email by checking a digital signature against a public key published in DNS for the sending domain. In a qmail setup, failures usually come from one of five places: a broken TXT record, the wrong selector, a missing or unreadable private key, message changes after signing, or inconsistent relay handling.

Quick checks first:

  • Confirm the selector and domain in the DKIM-Signature header match the published dkim record.
  • Query DNS directly for the selectors DNS record and compare the public key.
  • Check qmail signing tools such as qmail-dkim, dkimsign.pl, libdkim, libdomainkeys, or perl-Mail-DKIM.
  • Inspect the message source in Gmail, Microsoft 365, Exchange Online, Yahooメール, or Alibaba Cloud mailboxes.
  • Review authentication results for dkim=pass, dkim=fail, dkim=neutral, or dkim=temperror.

Why DKIM Fails Differently in Qmail

qmail is modular, which is useful but unforgiving. Unlike monolithic MTAs, a qmail deployment often depends on a wrapper, qmail-remote changes, QMAILQUEUE, or scripts such as dkimsign.pl and dkimverify.pl to add or check the digital signature.

That means DKIM troubleshooting is really path troubleshooting. You need to trace the email message from queue injection, through dkim signing, through outbound delivery, then into the receiving systems signature verification logic.

What Good Looks Like

A healthy DomainKeys Identified Mail flow has a stable canonicalized message, a matching selector, a valid private key, and a corresponding public key in DNS. The receiving mail server uses public key cryptography to compare the signed headers and body hash against the published key.

The DKIM configuration process involves several important checkpoints to ensure successful email authentication. First, perform a selector lookup to confirm that the public key is available in DNS, as a missing or incorrectly split TXT record can cause lookup failures. During the signing step, verify that the DKIM-Signature header is successfully added to outgoing emails, since an incorrect qmailqueue configuration or script path may prevent signing. Next, ensure that the signer can access the secret key, as incorrect file ownership or permissions can interfere with the process. The message body should also remain unchanged after signing because modifications caused by footers, relays, or MIME rewriting can invalidate the signature. Finally, check the receiving server’s authentication results and confirm that dkim=pass is returned. A failed message validation indicates that the DKIM signature has not been successfully verified.

Understanding How DKIM Works in Qmail Environments

DomainKeys Identified Mail uses public key cryptography to prove that an authorized system signed selected parts of an outgoing email for a specific domain. The receiving side can verify email without knowing the senders private key.

Spf Lookup 4110

DKIM Signing and Verification Flow

In qmail, dkim signing usually happens before delivery leaves the host. The signer creates a digital signature, adds a DKIM-Signature header, and passes the message back into the qmail delivery chain.

Core DKIM Header Fields

Signature verification depends on these header fields matching reality:

  • d=: the signing domain name
  • s=: the selector used to find the DNS record
  • h=: signed headers, such as From, Subject, and Date
  • bh=: body hash used for message validation
  • b=: the final digital signature

Standards Edge Case

RFC 6376 defines DKIM itself, while RFC 8301 tightened weak-key guidance and RFC 8463 introduced Ed25519 support. Older libdkim or libdomainkeys builds may not handle newer expectations, so signature verification can differ between Gmail, Microsoft 365, and Exchange Online.

Qmail Components That Commonly Handle DKIM

A qmail system may use qmail-dkim, perl-Mail-DKIM, or patched delivery components from projects such as corokada/return-qmail. Some administrators integrate dkimverify.pl for inbound checks and dkimsign.pl for outbound signing.

Where DKIM Sits in the Qmail Path

Some Qmail installations use the QMAILQUEUE environment variable through queue-injection modifications or patches to route outgoing messages through a signing program. Other implementations integrate DKIM signing into a modified qmail-remote delivery process. The exact configuration depends on the installed Qmail version and signing implementation.

Tooling Note

On Linux, installation paths vary. You may see yum install for dependencies, cpan for perl-Mail-DKIM, or make install after compiling qmail-dkim on Gentoo or another source-based system.

Verifying DNS DKIM Records and Selector Configuration

DNS errors cause many DKIM failures because receivers cannot complete public key cryptography checks without the public key. If the selector is wrong, the receiving system cannot verify email for that domain.

Query the DKIM TXT Record Directly

Find the selector from the DKIM-Signature header, then query:

dig TXT selector._domainkey.example.com

A correct TXT record should include v=DKIM1 and p= followed by the public key. In BIND, VALUE-DOMAIN, Alibaba Cloud DNS, or similar providers, long keys may be split across quoted strings, which is valid when DNS joins them correctly.

Sender Policy Framework Office 365 5500

Common DNS Record Problems

DNS record mistakes usually look simple:

  • Wrong selector published for the active signer
  • Old public key left after key rotation
  • Missing TXT record due to provider UI formatting
  • Wrong domain under d=, especially with subdomains
  • Propagation delay during migration or test mode

Provider-Specific Example

If TechMail sends as example.com but qmail signs as mail.example.com, receivers check different DNS names. Ask IT (askit.ttu.edu), Twilio, Gmail, and Yahooメール documentation all stress that the published selector must match the signers actual domain.

Compare DKIM With SPF and DMARC

DKIM is separate from SPF, but DMARC can use either aligned DKIM or aligned SPF to pass policy. While DKIM verifies email signatures, SPF authenticates the sending infrastructure. AutoSPF helps administrators manage SPF records, monitor DNS lookup limits, and reduce configuration issues that can affect email authentication and deliverability.

Alignment Matters

DMARC checks whether the authenticated domain aligns with the visible From: address. A message can have valid dkim verification yet still fail DMARC if d= does not align with the user-facing domain name.

Checking Qmail DKIM Signing Setup, Keys, and Permissions

A working qmail DKIM setup needs the signer to run, read the private key, select the right domain, and add a valid digital signature before any later component modifies the message.

Inspect the Signing Toolchain

Check which method your qmail host uses:

  • qmail-dkim compiled into or wrapped around outbound delivery
  • dkimsign.pl from perl-Mail-DKIM
  • libdkim or libdomainkeys integrations
  • A wrapper controlled by QMAILQUEUE
  • A custom patch to qmail-remote

Key Files and Permissions

The signer must read the secret key file but ordinary users should not. A safe pattern is restricted ownership by the qmail signing user and permissions such as 0600.

Generated Key Check

If your setup used dkim_keygen.sh, confirm the generated public key matches the published dkim record. Mismatched key pairs are a classic email authentication failure.

Confirm Signing Happens on the Right Messages

qmail can send mail through multiple routes. Local scripts, authenticated SMTP users, mailing list software, and relay paths may not all pass through the same qmailqueue or qmail-remote path.

Practical Test

Send one outgoing email from each source and inspect the message source. If one path has a DKIM-Signature header and another does not, your infrastructure signs only part of the mail stream.

Diagnosing Header, Relay, and Message Modification Issues

DKIM protects selected headers and the message body, so any modification after signing can break signature verification. This is common when a relay adds banners, rewrites MIME boundaries, or changes line endings.

Look for Post-Signing Changes

A receiver uses public key cryptography to validate the hash of the signed content. If a footer service appends text after dkim signing, the original digital signature no longer matches.

High-Risk Modifications

Watch for:

  • Mailing list footers added after signing
  • Antivirus disclaimers inserted by a relay
  • Subject rewriting, such as [EXTERNAL]
  • Header formatting changes that are incompatible with the selected DKIM canonicalization method.
  • MIME conversion between quoted-printable and base64

Relay Edge Case

A downstream relay may preserve DKIM-Signature but alter the body. The result is deceptive: DKIM appears present, yet signature verification fails because the signed content changed.

How To Create Spf Record 5201

Review Authentication Results From Receivers

The Authentication-Results header is your best clue. Microsoft 365, Exchange Online, Gmail, Alibaba Cloud, and Yahooメール often show whether email authentication failed due to body hash mismatch, missing key, policy, or temporary DNS lookup failure.

Useful Header Clues

Look for authentication results such as:

  • dkim=pass: receiver could verify email
  • dkim=fail: signature exists but failed validation
  • dkim=temperror: temporary DNS or lookup problem
  • dkim=permerror: malformed signature or bad TXT record

Testing, Logging, and Preventing Future DKIM Failures

Reliable DKIM operations need repeatable tests, log visibility, and change control across qmail, DNS, and the receiving mail server. Treat email authentication like production security infrastructure, not a one-time setup.

Run Controlled Message Tests

Use a known mailbox at Gmail, Microsoft 365, or another strict receiver. Send a plain-text test, an HTML test, and an attachment test, then compare the message source and authentication results.

Inbound Verification

If you run qmail-dkimverify or dkimverify.pl, log both pass and fail cases. Inbound message validation helps spot spoofing and confirms your parser understands modern DomainKeys Identified Mail headers.

Prevent Repeat Failures

Build a small DKIM operations checklist. It will save time during migrations.

  • Document selectors, key locations, and owner permissions.
  • Monitor DNS for accidental TXT record deletion.
  • Rotate keys with overlap between old and new selectors.
  • Test after qmail patches, package upgrades, and relay changes.
  • Keep SPF and DMARC aligned with the same sending domain strategy.

Maintenance Insight

Older qmail deployments often fail after unrelated changes: DNS provider migration, Linux package cleanup, or a replaced relay. Keep DKIM, SPF, and DMARC checks in every mail-change runbook.

Multiple Spf Records 9550

FAQ

Why does DKIM pass in Gmail but fail in Microsoft 365?

Gmail and Microsoft 365 may report different DKIM authentication results when they receive different message copies, encounter DNS lookup issues, or process messages modified by intermediate relays. Compare the Authentication-Results headers, DKIM selector, signing domain, and body hash results from both mailboxes to identify the underlying issue.

What to compare first

Check the same email message in both systems and compare Authentication-Results, selector, domain, and body hash status. If one receiver reports a malformed DKIM header, inspect folding and canonicalization.

Can qmail send mail without DKIM and still pass DMARC?

Yes, but only if SPF passes and aligns with the visible From domain. Without DomainKeys Identified Mail, DMARC depends on aligned SPF, which can break when forwarding or relaying changes the connecting IP.

Why DKIM is safer for forwarding

DKIM can remain valid when an email is forwarded without changes to its signed headers or body. However, forwarding services that add mailing list footers, modify subject lines, or rewrite message content can invalidate the signature. Qmail administrators should ensure that downstream mail systems preserve signed content whenever possible.

What is the fastest way to find the active DKIM selector?

Open the message source and read the s= tag in the DKIM-Signature header. That selector, combined with the d= domain, tells you exactly which DNS name the receiver used to verify email.

Example lookup format

For s=mail2024 and d=example.com, query mail2024._domainkey.example.com. If the TXT record is missing or contains the wrong key, dkim verification will fail.

Should I replace libdomainkeys with perl-Mail-DKIM?

Whether you should replace libdomainkeys with perl-Mail-DKIM depends on your Qmail configuration, implementation compatibility, maintenance status, and support for current DKIM standards. perl-Mail-DKIM provides Perl-based DKIM signing and verification capabilities, but switching implementations requires testing key compatibility, signing behavior, and message delivery before making production changes.

Upgrade caution

Test before replacing anything in production. A qmail signing change can affect every outgoing email, so validate the digital signature, selector, and DNS key before enforcing policy.

Brad Slavin
Brad Slavin

General Manager

General Manager of DuoCircle. Product strategy and commercial lead for AutoSPF's 2,000+ customer base.

LinkedIn Profile →

Ready to get started?

Try AutoSPF free — no credit card required.

Book a Demo