DomainKeys Identified Mail (DKIM)

DomainKeys Identified Mail (DKIM) adds a cryptographic signature to an outgoing message. The signing domain publishes the matching public key in DNS, so any receiving server can verify that the message really was sent by that domain and that the signed parts have not been altered in transit.

DKIM is defined in RFC 6376. Unlike SPF, it says nothing about which IP address a message came from — which is precisely why it survives forwarding.

What does a DKIM signature look like?

The signature travels in a header added by the sending server:

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=example.com; s=mail2026; t=1785830662;
	h=from:to:subject:date:message-id;
	bh=2jmj7l5rSw0yVb/vlWAYkK/YBwk=;
	b=Xk9pLq3vFn8sT2mR4wYcJ7dHgB1nZaQe6iU0oP5rKlM8...

The fields that matter when debugging:

Tag Meaning
d= the signing domain — what DMARC alignment is checked against
s= the selector, which names the DNS record holding the key
h= the list of headers covered by the signature
bh= hash of the message body
b= the signature itself
c= canonicalisation, almost always relaxed/relaxed

Where is the public key published?

At <selector>._domainkey.<domain> as a TXT record. The selector in the signature above is mail2026, so:

$ dig +short TXT mail2026._domainkey.example.com
"v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."

The selector exists so a domain can hold several keys at once. That is what makes rotation possible: publish the new selector, switch signing to it, and remove the old record only once nothing is still verifying against it.

How does verification work?

The receiving server reads d= and s= from the signature, fetches the public key from DNS, recomputes the body hash and the header hash, and checks them against bh= and b=. If both match, the message is intact and the signing domain is confirmed.

Only the headers named in h= are protected. Anything not listed can be added or changed without invalidating the signature, which is why from should always be included — and why a signature that covers only trivial headers proves very little.

What breaks a DKIM signature?

How do you check your own DKIM setup?

Look at a message you actually sent, as delivered. The receiving side records its verdict in Authentication-Results:

Authentication-Results: mx1.example.net;
	dkim=pass header.d=example.com header.s=mail2026;
	spf=pass smtp.mailfrom=example.com;
	dmarc=pass (p=reject sp=reject dis=none) header.from=example.com

dkim=pass with the expected header.d= is what you want. dkim=fail with a correct-looking record usually means something modified the message after signing; dkim=none means no signature was applied at all.

Why does DKIM matter for deliverability?

A verified signature gives receiving systems a stable identity to attach reputation to. IP addresses change, ranges are reassigned, and a shared sending platform mixes many customers on one address — but d=example.com is yours alone, and reputation accumulated against it follows you.

It is also one of the two authentication results DMARC can accept. Because DKIM survives forwarding and SPF does not, a domain with a strict DMARC policy and no DKIM signing will lose legitimate forwarded mail.

Howto block Google Groups spam in Rspamd shows the flip side of a valid signature: spam relayed through Google Groups is correctly signed by google.com, so DKIM passing tells you the message really came from Google — and nothing at all about whether you want it.