schedule 14-min read

What Is DKIM? DKIM Records, Signatures and Why DMARC Depends on It

DMARC AI editorial team · Last updated

What DKIM is, how signing and verification work, what each tag in a DKIM record and DKIM-Signature header means, and why DMARC relies on aligned DKIM.

01

What is DKIM?

DKIM (DomainKeys Identified Mail) is an email authentication standard in which the sending server adds a cryptographic signature to each message, and the receiver checks it against a public key published in DNS. A valid signature proves that the signing domain took responsibility for the message and that the signed content was not changed in transit.

DKIM is defined in RFC 6376, updated by RFC 8301 (algorithms and key sizes) and RFC 8463 (Ed25519 keys). It has two visible parts: the DKIM record, a TXT record holding the public key, and the DKIM-Signature header added to every signed message. This guide takes both apart tag by tag, then explains why DMARC depends on DKIM more than on SPF. For the wider picture, start at the DKIM pillar guide.

02

Key takeaways

  • A DKIM record is a TXT record at selector._domainkey.domain containing the public key in p=. An empty p= means the key is revoked.
  • The DKIM-Signature header names the signing domain (d=), the selector (s=), the signed headers (h=), a body hash (bh=) and the signature itself (b=).
  • RFC 8301 says rsa-sha1 must not be used, RSA keys must be at least 1024 bits, and signers should use 2048 bits.
  • DMARC only counts a DKIM pass when the d= domain aligns with the visible From domain, relaxed by default under RFC 9989.
  • DKIM usually survives plain forwarding because the signature travels inside the message, which is why it is the more dependable path to a DMARC pass.
03

How does DKIM signing and verification work?

The sender hashes selected headers and the body, signs the result with a private key and adds a DKIM-Signature header. The receiver reads d= and s= from that header, fetches the public key from DNS, recomputes the hashes and checks the signature. A match is dkim=pass; anything else is fail, neutral, temperror or permerror.

Step by step, as RFC 6376 describes it:

  1. Canonicalise. The signer normalises headers and body using the method in c= (simple or relaxed), so harmless whitespace changes do not break the signature.
  2. Hash the body. It hashes the canonicalised body (or the first l= bytes of it) and stores the result in bh=.
  3. Sign the headers. It hashes the header fields listed in h=, plus the DKIM-Signature header itself with an empty b=, and signs that hash with the private key. The result goes into b=.
  4. Look up the key. The receiver queries the TXT record at s= + ._domainkey. + d=.
  5. Verify. It recomputes bh=, checks it matches, then verifies b= with the public key.

RFC 6376 Section 5.4 makes one header compulsory: "The From header field MUST be signed", which is what lets DMARC build on DKIM.

04

What is a DKIM record?

A DKIM record is a DNS TXT record that publishes the public half of a signing key. It lives at <selector>._domainkey.<domain>, so a key with selector s2026 for example.co.uk sits at s2026._domainkey.example.co.uk. Receivers fetch it to verify signatures; the domain itself does not need one at its apex.

A realistic 2048-bit RSA record looks like this in zone file form:

s2026._domainkey.example.co.uk.  3600  IN  TXT  ( "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsAy7O+5HKMzVc81dw4TFHbwAiiNvGL2tBtfoklnU9DvzcLQxgan9ZqapjNsFAvU5pvpnT2uuKxKl5psTlsfH1VThwYQMXljbzPv0oeitj5T1uwn7UroxR618Ao3QsH3bdWpM5vsIFz0zW1SQQ4LME8IXJZ3yyl/OFomZr5DEZ9DTURybhNc8cVdfldyn4mHZY"
  "lUPkYSxQpbwnbOPziLUI9ifL7AJ/c/8NHtqJ7DOz+4GIdrwVT88KIfk4MZKvZ6oM0Tq/R1K1vIQqhnIFmfeJRrJtISQOhuH88AzHnbJoOkyyHnuKY67j3rhSnucPp1XLx2tEfXeA4higP9IoTNlvwIDAQAB" )

The selector is a free label chosen by whoever generates the key. Many platforms use their own naming, and some (Microsoft 365 is a common example) ask you to publish a CNAME at the selector name that points to a key the provider hosts, so the provider can rotate it. Selectors are covered in depth in DKIM selector explained.

What does each tag in a DKIM record mean?

The key record uses a short list of tag=value pairs separated by semicolons, defined in RFC 6376 Section 3.6.1. Only p= is required. In practice most records carry v=DKIM1; k=rsa; p=..., and the other tags are rare but worth recognising when you audit a client zone.

Tag Status Meaning
v=DKIM1 Recommended Version. If present, it must be exactly DKIM1 and must come first.
k= Optional, default rsa Key type: rsa, or ed25519 under RFC 8463.
p= Required The base64 public key. An empty value (p=) means the key has been revoked.
t= Optional Flags. y marks the domain as testing DKIM; s means the i= domain must not be a subdomain of d=.
h= Optional, default all Acceptable hash algorithms, for example h=sha256.
s= Optional, default * Service type. email limits the key to email; * allows all.
n= Optional Human-readable notes. Rarely used.

Two practical points. First, a revoked key is published as v=DKIM1; p=, which tells receivers the selector existed but must no longer verify. That is cleaner than deleting the record when you retire a key during DKIM key rotation. Second, t=y is not a soft launch. RFC 6376 says verifiers must not treat mail from a testing domain differently from unsigned mail, so leaving t=y on a production key quietly weakens it.

Why is a long DKIM key split into several strings?

A single TXT character-string can hold at most 255 octets (a DNS limit from RFC 1035), and a 2048-bit RSA record is around 410 characters. The record is therefore published as two or more quoted strings in one TXT record. RFC 6376 Section 3.6.2.2 says the strings "MUST be concatenated together before use with no intervening whitespace."

Most DNS panels split long values for you. Problems appear when the key is pasted as two separate TXT records, or with spaces or stray quotes inside the base64; the key then fails to parse for every message on that selector.

05

What does the DKIM-Signature header contain?

The DKIM-Signature header is a list of tags that tells the receiver who signed, which key to fetch, what was signed and how. It sits among the message headers and is visible in "show original" or "view source". An annotated example for a message signed by example.co.uk (values illustrative):

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.co.uk;
 s=s2026; t=1794557835; x=1795162635;
 h=from:to:subject:date:message-id;
 bh=tEoBPF7+f6jRPwGWYbLCMyVcdmZlEbocYDaK6u9Dxls=;
 b=nNgye4fG12URxmbfk/QOlxsrF8OUGIbWJFaOITSFBaTXW8pv0Q7kfuSid7+3rn8u6a4t6
 fCSwuXnA/UkUJC5ePXgIA7+QNZy/reNjg2gFc9sl6OpcP5iQ0gOk4ybgzoa4XZmIDydWbin
 diMXY/yrRUo15FtvYgH0eRHLTgc0AcVHdk+OPWT8TFcZpQ6K6Q3AMSfiaSJYIijrrJBogHe
 vQjnYyWbqMTPowbb50ROrq9rxsJvSJgNJAhFLuO/+Ialkb1KRqZ5x3HTI5z6kr2Vm2Frr8V
 3wiSZBzdrSrtiRsyBDem1XTmWTrrQ/m7/P2PBCmjLveAQ9dVOAbGGMx4ZCQA==

What does each DKIM-Signature tag mean?

Each tag has a fixed meaning in RFC 6376 Section 3.5. Seven are required (v, a, b, bh, d, h, s); t and x are recommended; the rest are optional with defaults. When troubleshooting, d=, s= and h= answer most questions, because they decide which key is fetched and what alignment DMARC sees.

Tag Status What it tells the receiver
v=1 Required Signature version. Always 1.
a= Required Algorithm: rsa-sha256 or ed25519-sha256. rsa-sha1 must not be used (RFC 8301).
c= Optional, default simple/simple Canonicalisation for headers/body. relaxed/relaxed tolerates whitespace and header case changes.
d= Required The signing domain (SDID). This is the domain DMARC checks for alignment.
s= Required The selector. Combined with d= to find the key record.
h= Required Colon-separated list of signed headers. Must include From.
bh= Required Base64 hash of the canonicalised body.
b= Required The signature itself, in base64.
t= Recommended Signing time, in seconds since 1970 (Unix time).
x= Recommended Expiry time. Verifiers may treat the signature as invalid after it.
i= Optional Agent or user identifier. Defaults to the d= domain with an empty local part. It must be the d= domain or a subdomain of it.
l= Optional, default whole body Body length counted in bh=. Content added after that length is unsigned, so most senders avoid l=.
06

Which DKIM key sizes and algorithms should you use?

Use RSA with SHA-256 and a 2048-bit key. RFC 8301 states that "rsa-sha1 MUST NOT be used for signing or verifying", that signers "MUST use RSA keys of at least 1024 bits", and that they "SHOULD use RSA keys of at least 2048 bits". Verifiers must not accept signatures made with RSA keys under 1024 bits.

Google's email sender guidelines require a key of 1024 bits or longer for mail to personal Gmail accounts and recommend 2048 bits where the DNS provider supports it. The UK NCSC's DKIM guidance also recommends a 2048-bit key and suggests rotating keys about every 12 months.

Ed25519 is the newer option. RFC 8463 adds a=ed25519-sha256 with k=ed25519 in the key record. The public key is only 44 base64 characters, so it fits in one TXT string:

ed2026._domainkey.example.co.uk.  3600  IN  TXT  "v=DKIM1; k=ed25519; p=EEj+CngncHG+I1MtNujUAxO6zgdzKdPrSHpEvxbvt3M="

Because not every verifier supports Ed25519, RFC 8463 notes that signers can add multiple signatures with old and new algorithms, each under its own selector. Treat Ed25519 as an addition to an RSA signature, not a replacement.

07

Why does DMARC depend on DKIM?

DMARC passes when SPF or DKIM passes and the passing domain aligns with the visible From domain. DKIM is usually the more reliable of the two because its d= domain can match the From domain on third-party platforms and it survives forwarding. In practice, aligned DKIM on every legitimate sender is what makes p=reject safe.

RFC 9989, which obsoletes RFC 7489, puts it plainly in Section 4.4.1: only a DKIM-authenticated identifier that aligns with the Author Domain counts, and when a message carries several signatures it produces a DMARC pass "if any DKIM-Authenticated Identifier aligns with the Author Domain." The adkim tag sets the mode:

  • Relaxed (adkim=r, the default): d= and the From domain share the same Organizational Domain. d=mail.example.co.uk aligns with a From address at example.co.uk.
  • Strict (adkim=s): d= must be identical to the From domain.

RFC 9989 also changes how the Organizational Domain is found, replacing sole reliance on the Public Suffix List with a "DNS Tree Walk". The details, and when strict mode is worth it, are in DMARC alignment explained.

Here is how three common senders score for a client whose From domain is example.co.uk:

Sender setup DKIM result d= domain DMARC via DKIM
Own mail platform signing with the client's key pass example.co.uk Pass (aligned)
Marketing platform with custom DKIM via a selector at example.co.uk pass example.co.uk Pass (aligned)
Same platform on default settings pass the platform's domain Fail (not aligned)

The third row is why "DKIM passes but DMARC fails" is such a common ticket. The fix is to enable the platform's custom-domain DKIM so it signs with the client's domain. SPF has a similar alignment problem with bounce domains, which is why SPF alone is not enough, but DKIM is easier to fix on most SaaS senders.

08

Why does DKIM survive forwarding when SPF does not?

SPF checks the IP address of the server connecting to the receiver. When a message is forwarded, the forwarder's IP is not in the original domain's SPF record, so SPF fails. DKIM does not look at IP addresses: the signature is inside the message, so it still verifies at the final hop if the signed headers and body arrive unchanged.

The weakness is modification. Mailing lists that add a subject tag or footer, and gateways that append disclaimers or rewrite links after signing, change the signed content and break the signature. The NCSC advises applying the DKIM signature last, after any footer or disclaimer is added, for exactly this reason. A list that re-signs with its own domain produces a valid signature, but it aligns with the list's domain, not the original author's. DMARC and email forwarding covers the cases where neither mechanism survives.

09

How do you look up and check a DKIM record?

You need the selector first, because DKIM records cannot be listed or guessed reliably. Take it from the s= tag of a real message's DKIM-Signature header, then query the TXT record at that selector under _domainkey. A result containing p= with key data means the key is published.

From a terminal:

dig +short TXT s2026._domainkey.example.co.uk

On Windows, nslookup -type=TXT s2026._domainkey.example.co.uk does the same. If the selector is a CNAME to a provider, dig follows it and shows the provider's TXT value. For a quicker check that also parses the tags, key length and revocation state, use the DKIM validator; to see which selector and d= domain a real message used, paste its headers into the email header analyzer.

What to look for in the result:

  • No answer (NXDOMAIN): wrong selector, record not yet published, or a typo in the host name (a common one is publishing s2026._domainkey.example.co.uk.example.co.uk because the DNS panel appends the zone name).
  • p= empty: the key is revoked. Mail still signed with it will fail.
  • Two TXT records at one selector: results are unpredictable. Keep exactly one.
10

How do you set up DKIM?

Setup happens on each sending platform: generate or enable a key, publish the record (TXT or CNAME) the platform gives you at its selector, switch signing on, then confirm dkim=pass with an aligned d= in a test message and in aggregate reports. The full walkthrough, platform by platform, is in how to set up DKIM.

11

How should MSPs manage DKIM across client domains?

Treat DKIM as an inventory problem. For each client domain, record every sending platform, its selector, key type and size, the d= domain it signs with, and when the key was last rotated. Aggregate reports show which sources pass DKIM with alignment and which fall back on SPF or fail outright.

A workable routine for a portfolio of client domains:

  1. Onboarding: collect DKIM results per source from at least a few weeks of aggregate reports under p=none before proposing enforcement.
  2. Change control: treat every new SaaS sender as a change request that includes custom-domain DKIM, not just an SPF include.
  3. Hygiene: flag 1024-bit keys, rsa-sha1, t=y left on production keys, and selectors still published for platforms the client has left.
  4. Rotation: schedule key changes under new selectors and revoke old ones with an empty p=.

Recurring problems such as orphaned selectors, keys owned by a departed contractor, and DNS panels that mangle long records are covered in DKIM management for MSPs. DKIM is necessary but not sufficient on its own; why DKIM alone is not enough explains the gap that DMARC policy closes.

12

FAQ

What is the difference between DKIM and a DKIM record?

DKIM is the whole signing standard: the private key, the signature added to each message and the verification process. The DKIM record is only the DNS part, a TXT record at selector._domainkey.domain that publishes the public key in p=. A domain can have several DKIM records, one per selector, for different platforms or keys.

Can a domain have more than one DKIM record?

Yes. Each selector holds its own key, so a client can have one selector for Microsoft 365, another for a marketing platform and a third for a ticketing system. A message can also carry several DKIM signatures. What a domain must not have is two different TXT records at the same selector name.

Why does DKIM pass but DMARC fail?

The signature is valid, but its d= domain does not align with the From domain. This usually means a third-party platform is signing with its own domain. Enable custom-domain DKIM on that platform so it signs as the client's domain, then confirm alignment in aggregate reports or with a test message.

Is a 1024-bit DKIM key still acceptable?

It meets the minimum in RFC 8301 and Google's sender guidelines, so mail will still verify. RFC 8301, Google and the NCSC all recommend 2048 bits, though. Treat 1024-bit keys as technical debt: replace them at the next planned rotation, using a new selector, rather than changing the existing record in place.

What does an empty p= in a DKIM record mean?

It means the key has been revoked. RFC 6376 defines an empty p= as a public key that "has been revoked", so any signature using that selector fails verification. Publishing v=DKIM1; p= after a rotation is a clean way to retire an old key while showing receivers it was deliberately withdrawn.

Related articles

Related tools

Ready to Implement?

Get authenticated mail moving in minutes: start free, book a guided demo, or talk to the team about your stack.