DKIM adds a signature to every message you send and publishes the matching public key in your DNS. A receiver fetches the key and checks the signature, which fails if the signed parts of the message changed after signing [1]. One domain can publish many keys, one per service, each under its own selector.

The short answer

A DKIM record is a TXT record at selector._domainkey.example.com that holds a public key, such as v=DKIM1; k=rsa; p=MIIBIjAN…. A receiver takes the domain from the signature’s d= tag and the selector from its s= tag, fetches that record and checks the signature [1]. Use RSA keys of 2048 bits [2].

Anatomy of a DKIM record

Each message carries a DKIM-Signature header. Two of its tags name the key [1]:

DKIM-Signature: v=1; a=rsa-sha256; d=example.com; s=google; ...

d= is the signing domain and s= is the selector. Together they give the name of the key: google._domainkey.example.com [1]. At that name sits a TXT record with the key. The key below is shortened; your provider gives you the full value.

google._domainkey.example.com.  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
Tag Example What it does If you leave it out
v v=DKIM1 Version. If present, it must be DKIM1 and come first [1]. Assumed DKIM1
k k=rsa Key type: rsa, or ed25519 under RFC 8463 [1][3]. rsa
p p=MIIBIjAN… The public key in base64. Required. An empty p= means the key is revoked [1]. Record is invalid
h h=sha256 Hash algorithms this key accepts [1]. All
t t=y Flags. y means the domain is testing DKIM, and receivers must treat its mail like unsigned mail [1]. No flags
s s=email Service types the key is for [1]. All (*)
n n=newsletter_key A note for humans; programs ignore it [1]. Empty

A long key may not fit in a single TXT string. DNS panels then split it into several quoted strings, and receivers join them with nothing in between [1].

How a DKIM signature works

The sending server signs each message and adds the result as a DKIM-Signature header. Here is one with its long values shortened:

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=google;
        h=from:to:subject:date:message-id; bh=2jUSOH9NhtVGCQ...; b=AuUoFEfDxTDkHlLX...
Tag What it holds
v The version, 1 [1].
a The algorithm: rsa-sha256, or ed25519-sha256 under RFC 8463. rsa-sha1 must not be used [2][3].
c How the headers and the body are normalized before hashing, simple or relaxed for each. Without it, simple/simple [1].
d The signing domain, under which the receiver looks up the key [1].
s The selector, which names the key under d= [1].
h The header fields the signature covers, in order. From must be one of them [1].
bh A hash of the message body [1].
b The signature, made over the headers listed in h= and over this DKIM-Signature header with b= left empty [1].

To verify, the receiver fetches the key at google._domainkey.example.com, hashes the body and compares the result with bh=. If they differ, the whole signature fails, even when the signed headers are intact [1]. Then it checks b= against the signed headers with the key [1]. A change after signing to the body or to any header in h=, beyond the spacing and line breaks that c=relaxed allows for, makes the check fail [1]. Since From is always signed, the From address can’t be changed without breaking the signature [1].

How to find your DKIM selector

A selector is any name you or your provider pick [1], and a DNS query only answers for a name you already know. That is why a checker tries common selectors or asks you for yours. Four places tell you for sure:

  1. A message you sent. Open its headers and read the s= tag of DKIM-Signature. Google’s DKIM help gives the same method [6].
  2. Your DNS panel. Look for TXT records with a DKIM key, or CNAME records to your mail provider, at names that end in ._domainkey. Everything in front of ._domainkey is the selector [1].
  3. Your DMARC reports. RFC 9990 requires every DKIM result in an aggregate report to name its selector [5]. Before RFC 9990 it was not required, so reports from some receivers may still leave it out [5]. How to read a DMARC aggregate report shows where.
  4. The email test. Send it a message from your domain and it shows the selector of each signature, with a link to check that key.

Selectors that common providers use, from their documentation:

Provider Selector What you publish
Google Workspace google (the default prefix) TXT with the key [6]
Microsoft 365 selector1 and selector2 CNAME to Microsoft [8]
Fastmail fm1, fm2 and fm3 CNAME to Fastmail [9]
SendGrid, with automated security s1 and s2 CNAME to SendGrid [10]
Cloudflare Email Routing cf2024-1 TXT with the key, added by Cloudflare [11]

Services outside this list can use names no checker can guess. The DKIM checker lets you type your selector in.

TXT or CNAME?

Some providers give you the key to publish as TXT, as Google Workspace does [6]. Others give you a CNAME that points to a name on their side, where they publish the key: Microsoft 365, Fastmail and SendGrid work this way [8][9][10]. A receiver that queries your selector follows the CNAME and reads the key at its target [12].

With a CNAME, the provider can change the key without you touching DNS. Microsoft 365 uses its two selectors for this: only one is active at a time, and the other takes over at the next key rotation [8].

Key length: 1024 or 2048 bits?

RFC 8301 sets the floor. Signers must use RSA keys of at least 1024 bits and should use 2048, and receivers must not accept signatures made with shorter keys [2]. Gmail requires a key of 1024 bits or more for mail to personal Gmail accounts and recommends 2048 [7]. Google Workspace offers both lengths and recommends 2048 if your DNS host supports it [6].

The hash matters too. RFC 8301 forbids rsa-sha1 for signing and for verifying [2], so a key record limited to h=sha1 can’t verify any signature a receiver accepts [1][2].

Ed25519 keys (k=ed25519) are valid too. RFC 8463 requires receivers to support them and only recommends them for signers, and it notes that a signer can add an RSA signature next to the Ed25519 one for backward compatibility [3].

DKIM and DMARC

A DKIM pass counts for DMARC only when d= matches your From domain, or shares its organizational domain under relaxed alignment [4]. A service that signs with its own domain passes DKIM, and that pass does not count toward DMARC for you. The DMARC record page explains alignment. SPF is the other method DMARC accepts, and the SPF record page covers it.

Problems and fixes

DKIM records from a provider you left

Your DNS still has selector1._domainkey or fm1._domainkey records for a service you stopped using. Read DKIM records still pointing at your old provider.

A selector that points nowhere

The checker reports a dangling CNAME on one of your selectors. Read Dangling DKIM CNAME records.

Check your DKIM records

The checker tries the selectors common providers use, plus any you type in, and reports each key’s type, length and state.

Check your DKIM records

Runs in your browser. Your domain is not sent to this site or stored.

Guides in this topic

Sources

  1. 1RFC 6376, DomainKeys Identified Mail (DKIM) Signatures. Sections 1.5, 3.1, 3.4, 3.5, 3.6.1, 3.6.2.1, 3.6.2.2, 3.7, 5.4, 6.1.2 and 6.1.3rfc-editor.org, IETF. Checked .
  2. 2RFC 8301, Cryptographic Algorithm and Key Usage Update to DomainKeys Identified Mail (DKIM). Sections 3.1 and 3.2rfc-editor.org, IETF. Checked .
  3. 3RFC 8463, A New Cryptographic Signature Method for DomainKeys Identified Mail (DKIM). Sections 3, 4.1, 5 and 6rfc-editor.org, IETF. Checked .
  4. 4RFC 9989, Domain-Based Message Authentication, Reporting, and Conformance (DMARC). Section 4.4.1rfc-editor.org, IETF. Checked .
  5. 5RFC 9990, Domain-Based Message Authentication, Reporting, and Conformance (DMARC) Aggregate Reporting. Section 3.1.1.12 and Appendix Crfc-editor.org, IETF. Checked .
  6. 6Set up DKIMknowledge.workspace.google.com, Google. Checked .
  7. 7Email sender guidelinessupport.google.com, Google. Checked .
  8. 8Set up DKIM to sign mail from your cloud domainlearn.microsoft.com, Microsoft. Checked .
  9. 9Manual DNS configurationfastmail.help, Fastmail. Checked .
  10. 10Configure domain authenticationtwilio.com, Twilio SendGrid. Checked .
  11. 11Domain configuration (Email Routing DNS records)developers.cloudflare.com, Cloudflare. Checked .
  12. 12RFC 1034, Domain Names: Concepts and Facilities. Section 3.6.2rfc-editor.org, IETF. Checked .