---
title: "DomainKeys Identified Mail (DKIM)"
description: "DKIM adds a cryptographic signature to outgoing email so receiving servers can verify the message really came from the domain and was not altered."
url: "https://mailmum.io/glossary/domainkeys-identified-mail-dkim/"
---

# 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](https://www.rfc-editor.org/rfc/rfc6376). Unlike
[SPF](https://mailmum.io/glossary/sender-policy-framework-spf/), it says nothing about which IP
address a message came from &mdash; 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:

```txt
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 &mdash; 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:

```sh
$ 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 &mdash; and why a signature that covers only trivial headers proves
very little.

## What breaks a DKIM signature?

* **Mailing lists.** Adding a subject prefix or a footer changes the body, so
  `bh=` no longer matches. This is the problem the ARC protocol was created to
  work around, and the reason mailing lists often rewrite the `From:` header of
  DMARC-protected domains.
* **Content filters and gateways** that append a disclaimer, rewrite links, or
  convert the character set after signing.
* **A missing or malformed DNS record**, including one that has been split
  incorrectly across TXT strings.
* **Keys that are too short.** 512- and 1024-bit RSA keys are increasingly
  distrusted; 2048-bit is the working default.
* **Signing before the message is final.** The signature must be applied last,
  after every modification your own infrastructure makes.

## 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`:

```txt
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 &mdash; but `d=example.com` is
yours alone, and reputation accumulated against it follows you.

It is also one of the two authentication results
[DMARC](https://mailmum.io/glossary/domain-based-message-authentication-reporting-and-conformance-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.

## Related reading

[Howto block Google Groups spam in
Rspamd](https://mailmum.io/posts/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
&mdash; and nothing at all about whether you want it.
