DKIM ties a message to the domain responsible for it: the server adds a digital signature to the headers, and the receiver checks it against the public key published in DNS. The signature confirms that the signed parts of the message were not altered in transit and that they were signed by whoever holds the domain’s private key.
How it works
- The sending server computes a hash of the message body and of selected headers and signs it with the private key.
- The result is added to the
DKIM-Signatureheader: the signing domain (d=), the selector (s=), the body hash (bh=), the list of signed headers (h=) and the signature itself (b=). - The receiver requests the TXT record
selector._domainkey.domain, takes the public key from thep=field and verifies the signature.
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=AuUoFEfDxTDkHl... mail2026._domainkey.example.com. IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEF..."The selector is an arbitrary name, so one domain can have several keys: for different servers and mailing services. To rotate a key, publish a new selector and only then switch signing over.
Algorithms and key length
| Item | Requirement |
|---|---|
| Algorithm | rsa-sha256; rsa-sha1 has been forbidden since RFC 8301 (2018) |
| RSA key length | at least 1024 bits, 2048 or more recommended |
| Ed25519 | ed25519-sha256 was added in RFC 8463 (2018) |
A 2048-bit key does not fit in a single TXT string, which is limited to 255 bytes, so the value is split into several strings within one record. The signature breaks if the signed parts of a message are changed along the way: for example, if a mailing list adds a tag to the subject or a footer to the body.
The main standard is RFC 6376 (September 2011, editors Dave Crocker, Tony Hansen and Murray Kucherawy).
Sources
the term is written from these pagesVerified 9 Nov