LearnEmail authentication

What is DKIM?

DKIM attaches a cryptographic signature to every message you send. Your server signs chosen headers and the body with a private key; the matching public key is published in DNS. A receiver fetches it, recomputes the hash, and learns two things: the message really came from your domain, and nothing it signed has changed since.

Written by the SieveGuard team from the checks our own free tools run. Last reviewed .

What the signature actually covers

Not the whole message. DKIM signs a chosen list of headers plus a hash of the body, and the header list is itself named in the signature so a receiver knows what to verify. Here is a real signature with the parts that matter:

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yourdomain.com;
    s=google; h=from:to:subject:date:message-id; bh=X0hLp…; b=fRkT9…
                 │                                  │        └ signature over the headers in h=
                 └ exactly which headers are signed  └ hash of the body
TagMeansWhy you care
d=The signing domainThis is what DMARC checks for alignment
s=The selector — which key to fetchIts own page
h=The list of signed headersAnything absent from this list is unprotected
bh=Body hashChanges if a single body byte changes
a=Algorithm, normally rsa-sha256ed25519 exists; support is still thin
c=Canonicalisation, normally relaxed/relaxedGoverns how much reformatting survives
l=Body length to sign — optionalOmit it. See below

The h= list is the security-relevant one and almost nobody looks at it. A header not named there can be added or altered in transit and the signature still verifies. Signing from is non-negotiable; a signature that omits it proves essentially nothing useful.

Why DKIM survives forwarding and SPF does not

This is the practical reason DKIM carries more weight at the large mailbox providers, and it follows directly from what each one checks.

SPFDKIM
ChecksThe connecting IP addressA signature travelling inside the message
Survives a forward?No — the IP changesYes — the signature travels with it
Survives a mailing list?NoOnly if the list does not rewrite the body
Needs the receiver to trust DNSYesYes
Breaks if a byte of the body changesNoYes — that is the point

A mailing list that appends a footer breaks the body hash and therefore the signature. That is not a bug; it is DKIM correctly reporting that the message was modified. It is also why ARC exists — to let a trusted intermediary vouch that authentication passed before it made its changes.

Key length: use 2048

1024-bit RSA keys still verify everywhere. They are also below what Gmail and Outlook consider adequate, and both have signalled they will stop treating them as a full pass. There is no upside to staying on one.

The reason people do is mechanical rather than principled: a 2048-bit public key does not fit in a single 255-byte DNS character-string, so it has to be published as multiple quoted strings inside one TXT record.

"v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA…first part…"
"…second part…IDAQAB"

Two strings, one record — resolvers concatenate them with no separator. Most DNS providers handle the split automatically; a few require you to do it, and a few silently truncate, which produces a key that looks published and never verifies.

4096-bit is possible and rarely worth it: the record grows further, some resolvers struggle with the response size, and the security gain over 2048 is not the thing limiting your deliverability.

TXT or CNAME — both are normal

You hold the key (TXT)

You generate the pair, publish the public half as TXT, and load the private half into your mail server. Full control; you own rotation. Our generator does this in the browser, so the private key never crosses the network.

The provider holds the key (CNAME)

You publish a CNAME pointing at a record the provider hosts. They can then rotate the key without you touching DNS — which is genuinely better operationally, and is why most ESPs default to it. The lookup follows the CNAME transparently.

The failure mode is specific to this arrangement: some DNS hosts "flatten" a CNAME into the value it resolved to at the time of entry. That freezes a key which the provider expects to rotate, and DKIM fails months later for no visible reason.

Two things not to do

  • Do not use the l= tag. It limits signing to the first N bytes of the body, so anything appended afterwards is unsigned and the signature still verifies. That is an open invitation to append content to your signed mail. It exists for historical mailing-list compatibility and should be left in history.
  • Do not retire an old selector the moment you publish a new one. Mail signed with the old key is still in flight and still in inboxes. Leave the old record published until everything signed with it has aged out — a couple of weeks is generous, and the cost of leaving it is nil.

What a DKIM failure costs

On its own, less than people expect. A DKIM failure is not a rejection — receivers weigh it. What makes it expensive is DMARC: if DKIM is your only aligned authentication method and it fails, DMARC fails, and then your published policy decides what happens.

Which is the argument for having both SPF and DKIM aligned rather than one. Direct mail typically has SPF alignment; forwarded mail typically has only DKIM. Cover both and alignment holds in both cases.

Sources

FAQ

What does DKIM prove that SPF does not?+

That the message content is unaltered, and that the signing domain vouched for it. SPF only proves the connecting server was authorised — it says nothing about whether anything in the message changed afterwards.

Should I use a 1024-bit or 2048-bit key?+

2048. 1024-bit keys still verify but both Gmail and Outlook treat them as weak, and the only real reason people stay on them is that a 2048-bit public key has to be published as multiple quoted strings inside one TXT record.

My provider gave me a CNAME instead of a TXT record. Is that wrong?+

No, it is the normal modern pattern. The CNAME points at a TXT record the provider hosts so they can rotate the key without you touching DNS. Just confirm the CNAME actually resolves, and check your DNS host has not flattened it into a static value.

Can one domain have several DKIM keys?+

Yes, and it should — one per sending service, each under its own selector. Each service signs with its own key and receivers fetch whichever the signature names. There is nothing to coordinate between them.

Does DKIM stop someone spoofing my domain?+

Not by itself. An attacker simply sends unsigned mail, and DKIM alone gives the receiver no instruction about what to do with that. DMARC is the part that says refuse it — DKIM supplies the evidence DMARC acts on.

Why does DKIM fail on mailing lists?+

Because most lists modify the message — a subject tag, an appended footer. That changes the body hash the signature covers, so verification correctly fails. ARC exists so a trusted list can attest that authentication passed before it made those changes.

Check it on a real domain

Free, no signup, DNS-only. Nothing you type leaves the lookup.

Keep reading