Skip to content
SpoofKiller
Fundamentals

What Is DKIM? Email Signatures Explained

How DKIM signs a message, what a selector is, and why a valid signature is not the same as an aligned one.

Reading time
6 min read
Last updated
Updated
Rows of keys hanging on a locksmith's board, with one bright yellow key among them.
One domain, many keys. The selector tells the receiver which one to take down from the board.
In this guideShow 7 sections

For several centuries, a letter of consequence was closed with a blob of wax and the impression of a ring. The seal did two jobs. It showed who had sent the letter, since only one person had the ring, and it showed that nobody had opened the letter on the way, since wax does not reseal politely. Then the world moved to email and, for about twenty-five years, sent everything unsealed.

DKIM is the seal, reinvented with mathematics. It is more reliable than wax and considerably harder to explain at dinner. It also carries a subtlety that the wax seal did not: a perfectly valid seal can belong to someone other than the person named at the top of the letter. That gap is where a good deal of DKIM confusion lives.

What DKIM is

DKIM, DomainKeys Identified Mail, is defined in RFC 6376. A sending mail server uses a private key to compute a digital signature over parts of each outgoing message and adds the signature as a header. The matching public key is published in the sending domain’s DNS. Any receiver can fetch the public key and confirm two things: that the signed content has not changed since it was signed, and that the signer holds the private key belonging to the domain named in the signature.

Nothing is encrypted. The message remains as readable as a postcard. DKIM is about integrity and origin, not secrecy.

Anatomy of a signature

Here is a DKIM-Signature header, trimmed for length:

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
    d=example.com; s=mail2026;
    h=from:to:subject:date:message-id;
    bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=;
    b=AuUoFEfDxTDkHlLXSZEpZj79LICEps6eda7W3deTVFOk4yAUoqOB...
TagMeaning
d=The signing domain. This is the domain that takes responsibility, and the one DMARC compares with the From address.
s=The selector: which of the domain’s keys was used.
a=The algorithm, almost always rsa-sha256.
h=The list of headers covered by the signature. The From header must be among them.
bh=A hash of the message body.
b=The signature itself, computed over the listed headers and the body hash.
c=Canonicalization: how much whitespace and header reformatting to forgive, for headers and body respectively. relaxed forgives small changes; simple forgives almost none.

You can find this header in any signed message you have received. Paste the full headers into the email header analyzer to see each signature and the verdict the receiver reached.

Selectors, and where the public key lives

A domain can have many DKIM keys at once: one for the office mail system, one for the newsletter service, one for the billing platform. The selector tells the receiver which to fetch. The public key is a TXT record at a name built from the selector and the domain:

mail2026._domainkey.example.com.  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A..."

Some providers have you publish a CNAME at that name instead, pointing to a key they host, which lets them rotate the key without asking you to edit DNS again.

One practical consequence is easy to miss: there is no way to ask DNS for a list of a domain’s selectors. A receiver learns the selector from the message in front of it. A checking tool has no message, so it can only test selectors you name or ones that providers commonly use. That is how the free DKIM checker works, and it is why an empty result means “not found under those names,” not “this domain has no DKIM.”

How a receiver verifies it

  1. Read d= and s= from the signature and fetch the TXT record at s._domainkey.d.
  2. Hash the message body and compare the result with bh=. If they differ, the body was changed. Fail.
  3. Using the public key, check the signature in b= against the headers listed in h=. If it does not verify, a signed header was changed or the key is wrong. Fail.
  4. Otherwise, pass, and record the signing domain.

A message can carry several signatures, and each is checked independently. If the DNS record is missing, the result is a failure for that signature. If the record exists but its p= value is empty, the key has been deliberately revoked.

Valid is not the same as aligned

Here is the subtlety. DKIM verifies that the message was signed by the domain in d=. It says nothing about whether d= has any relation to the address in the From header. Consider a message sent through an email service that has not been configured with your domain:

From: Example Co <news@example.com>
DKIM-Signature: v=1; a=rsa-sha256; d=mailer-platform.net; s=k1; ...

That signature is valid. The platform signed its own mail with its own key, and any receiver will confirm it. But the seal is the platform’s, not yours. DMARC asks whether the signing domain aligns with the From domain, and mailer-platform.net does not align with example.com. DKIM passes; DMARC gets no credit from it.

A valid signature proves somebody sealed the letter. Alignment asks whether it was the person whose name is at the top.

The fix is to have the service sign with your domain, which every reputable provider supports: you add the DNS records they give you, and their signatures begin carrying d=example.com, or a subdomain of it, which aligns under the default relaxed mode. DMARC alignment, relaxed and strict, is covered separately. The provider guides, such as those for Google Workspace and SendGrid, give the steps for each console.

What breaks a signature, and what does not

DKIM’s great advantage over SPF is that the signature is part of the message. When mail is forwarded from one server to another, SPF fails at the new hop, but the signature goes along unchanged and still verifies. This is why an aligned DKIM signature is the sturdiest way to pass DMARC.

Sturdy is not indestructible. A signature breaks when the signed content changes:

  • A mailing list appends an unsubscribe footer or adds a tag to the subject line.
  • A security gateway rewrites links or inserts a warning banner into the body.
  • A relay re-encodes the message, altering the body in ways canonicalization does not forgive.

None of these is forgery, and all of them produce a DKIM failure. It is one of the reasons a DMARC failure, taken alone, proves nothing about intent.

Key length, rotation, and upkeep

The strength of the seal depends on the key. Keys of 1024 bits are the minimum receivers accept, and 2048 bits is the sensible default today; anything shorter than 1024 is treated as no signature at all. A 2048-bit public key is longer than the 255 characters a single DNS string may hold, so it must be entered as several quoted strings within one TXT record. Most DNS hosts split it for you. When one does not, the key is silently truncated, and every signature fails. It is among the most frequent entries in the catalog of common DKIM errors.

Keys should also be rotated: publish a new selector, switch signing to it, and retire the old one after mail signed with it has had time to be delivered. Many providers handle this themselves. What no provider handles is your DNS: a selector record deleted during a tidy-up will fail every message signed with it, starting immediately and without announcement. DKIM monitoring checks the selectors you rely on, on a schedule, and reads your DMARC reports to confirm that signatures are not merely valid but aligned.

To see where your domain stands, run a domain health check; it tests common selectors along with SPF and DMARC. Then make sure every service that sends as you is signing as you. The wax, at least, you no longer have to melt yourself.

FAQ

Questions about What Is DKIM

Short answers to what readers ask next. If yours is missing, write to us and a person will reply.

Ask a question

Free, no obligation

Want a second pair of eyes on your records?

Send us your domain. We will look at its DMARC, SPF, and DKIM setup and write back, in plain English, with what we found and what to fix first.

  • A person reads your records, not a script
  • Specific fixes, in order of importance
  • No sales sequence afterward

We use your details to reply. Nothing else.

Reading about it is the slow way.

Run the free check and see your own domain's DMARC, SPF, and DKIM in the time it took to read this paragraph. No account, no card.