Why DKIM verification fails (and how to fix each cause)

DKIM verification fails for four main reasons: the selector in the message header doesn't match a published DNS record, the public key was truncated when pasted, something modified the message body after signing, or the record was added with the wrong host. Query the selector directly with dig TXT selector._domainkey.yourdomain.com to tell which.
Unitpost ·
DKIM signs each message with a private key. You publish the matching public key in DNS, and the receiver fetches it to check the signature. A valid signature shows the message is authentic and wasn't changed on the way. A failed check is worse than having no DKIM at all, because to the receiver it looks like tampering.
Find the selector, then query it
Every DKIM signature names its own selector. Open the raw source of a message you received and find the DKIM-Signature header. The s= tag is the selector and d= is the signing domain. Query that exact record:
# From the DKIM-Signature header: s=selector1; d=yourdomain.com
dig TXT selector1._domainkey.yourdomain.com +shortIf the query returns nothing, the record isn't where the signature says it is. That's cause 1 or cause 3 below.
Cause 1: selector mismatch
A domain can publish several keys, each under its own selector. After a key rotation, or after copying a record from another provider's instructions, mail can go out signed with a selector that has no record in DNS. Publish the record for the selector named in the s= tag. Nothing about the signature needs to change.
Cause 2: the public key was truncated
A 2048-bit public key is longer than 255 characters, the limit for a single TXT string. Some DNS dashboards cut the value off without warning. Others make you split it into several quoted strings, which resolvers join back together.
A truncated key still resolves, so the record looks fine in dig and fails every check. This is the most confusing version of the failure. Unitpost's domain check reports it as "The DKIM value at selector._domainkey.yourdomain.com is incomplete. Copy it again."
Compare lengths
Compare the p= value in DNS with the one you were given, character by character. If the DNS copy is shorter, it was cut off. Several quoted strings inside one record is correct. Several separate TXT records is wrong.
Cause 3: wrong host field
The record belongs at selector._domainkey. Many DNS hosts append your domain to whatever you type, so entering the full name creates selector._domainkey.yourdomain.com.yourdomain.com. Query the record to see where it landed instead of trusting the DNS dashboard.
Unitpost looks for the doubled name and tells you directly: "Your DNS host added yourdomain.com to the DKIM name", followed by the name to use instead.
Cause 4: the message changed after signing
The signature covers a hash of the body and selected headers. If either changes after signing, the hash no longer matches. The usual causes are a mailing list that appends a footer, a security appliance that rewrites links, and forwarding rules.
If mail you send directly verifies but forwarded copies fail, this is the reason. You can't fix it from the sending side.
Rotating a DKIM key without downtime
Rotation is where teams cause their own outages. If you delete the old record as soon as you switch signing, mail that is still in flight, signed with the old key, fails verification. The safe order is make-before-break:
- Publish the new key under a new selector.
- Query it and confirm it resolves.
- Switch signing to the new selector.
- Remove the old record once no mail is signed with it.
