On this page
  1. What is DKIM (DomainKeys Identified Mail)?
  2. How DKIM signing and verification work
  3. The DKIM record and its tags
  4. DKIM selectors: what they are and how to find yours
  5. DKIM key length and key rotation
  6. DKIM keys for each sending service
  7. How to check your DKIM record
  8. What happens when DKIM fails
  9. FAQ

What Is DKIM?

DKIM (DomainKeys Identified Mail) is an email authentication method in which your sending server signs each message with a private key and publishes the matching public key in DNS, so the receiving server can verify the message came from your domain and was not changed in transit.

Written by Relay, the Email Stack Review teamPublished Updated No ads or affiliate links
Choosing a sending service? See the best transactional email services.

You are probably here because a sending service just handed you a few DNS records and told you to add them, or because a message failed a DKIM check. This page explains what those records do, how a receiver uses them, what a selector is, how often to rotate keys, and who holds the keys at each of the major sending services.

Key takeaways

  • DKIM is a digital signature on each message. The private key signs; the public key sits in DNS at selector._domainkey.yourdomain.com so any receiver can check it.
  • With a sending service you do not generate the key. You add the CNAME or TXT records the service shows you, then verify.
  • RFC 8301 says signers must use RSA keys of at least 1024 bits and should use 2048. M3AAWG says to rotate keys at least every six months.
  • Key handling differs by service: some hold and rotate the keys for you behind CNAMEs, others give you a TXT key you manage. The table below has all nine.
  • DKIM alone does not check the visible From address. DMARC does that, using a DKIM or SPF pass that aligns with it.

What is DKIM (DomainKeys Identified Mail)?

DKIM (DomainKeys Identified Mail) is an email authentication method in which your sending server signs each message with a private key and publishes the matching public key in DNS, so the receiving server can verify the message came from your domain and was not changed in transit. The standard is RFC 6376, an Internet Standard.

In the RFC's own words, DKIM lets the organization that owns the signing domain "claim some responsibility for a message". It separates the identity of the signer from the author named in the From header.

That tells you what DKIM proves and what it doesn't. A pass proves that a holder of the key for the signing domain signed this message, and that the signed parts weren't altered afterwards. It does not say the message is wanted. It also does not check the visible From address by itself: the signing domain in the d= tag can differ from the From domain. Matching the two is DMARC alignment, covered in SPF, DKIM and DMARC explained.

How DKIM signing and verification work

DKIM works in five steps: the sender hashes and signs, the receiver reads two tags, fetches the public key from DNS and checks the signature. The diagram shows the path; the steps follow it.

  1. The sending server hashes the body and the chosen headers, then signs the hash with a private key that only it holds.
  2. It adds the result as a DKIM-Signature header.
  3. The receiving server reads the d= (signing domain) and s= (selector) tags in that header.
  4. It fetches the public key from DNS at <selector>._domainkey.<domain>. RFC 6376 §3.6.2.1 says all DKIM keys live in a subdomain named _domainkey.
  5. It recomputes the hash and checks the signature against the public key. A match is a pass.

Here is a signature header. It is based on the example in RFC 6376 Appendix A, with the b= value shortened.

DKIM-Signature: v=1; a=rsa-sha256; s=brisbane; d=example.com;
     c=simple/simple; q=dns/txt; i=joe@football.example.com;
     h=Received : From : To : Subject : Date : Message-ID;
     bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=;
     b=AuUoFEfDxTDkHlLXSZEpZj79LICEps6eda7W3deTVFOk4yAUoqOB...

Example from RFC 6376, Appendix A, not a real signature. The tags that matter (RFC 6376 §3.5):

Tag Meaning In the example
v Version of DKIM (required) 1
a Signing algorithm rsa-sha256
d Signing domain example.com
s Selector, which tells the receiver which key to fetch brisbane
h Header fields that were signed Received : From : To : Subject : Date : Message-ID
bh Hash of the canonicalized body 2jUSOH9...
b The signature itself AuUoFEf...
c Canonicalization, how the message is normalized before hashing (default simple/simple) simple/simple

The receiver in that example queries brisbane._domainkey.example.com.

Does DKIM survive a trip through other servers? Usually. RFC 6376 notes that relays typically make no substantive change to the message, so the signature is preserved. When a message is forwarded unchanged, the signature normally still verifies; which is why DKIM usually survives forwarding where SPF often doesn't. When something edits the signed body, such as a mailing list adding a footer, the body hash no longer matches and the check fails. Fixes for failures are on fix SPF, DKIM and DMARC failures.

The DKIM record and its tags

A DKIM record is a DNS record at selector._domainkey.yourdomain.com that holds the public key: a TXT record with the key in it, or a CNAME that points to a TXT record the service hosts. You publish it in your DNS, because only the owner of the domain can.

Example for example.com, with a shortened key:

brisbane._domainkey.example.com.  IN TXT  "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ..."

The tags (RFC 6376 §3.6.1):

Tag Meaning
v Record version, DKIM1
k Key type; the default is rsa
p The public key, base64. An empty value means the key has been revoked
t Flags, such as y for a domain that is testing DKIM
s Service type, default * (all)
h Acceptable hash algorithms

With a sending service, you usually never type that value. The service shows a hostname and a value; you add them at your DNS host. If you do paste a long key into a TXT record, watch two things. A DNS TXT string holds at most 255 characters, so a 2048-bit key has to be split into several quoted strings; Amazon's Route 53 docs describe exactly that (Route 53 TXT records, checked November 2026), and Brevo's and Mailjet's DKIM docs warn about it too. And a stray line break or space inside p= makes the key unreadable.

DKIM selectors: what they are and how to find yours

A DKIM selector is the name in front of ._domainkey that tells a receiver which key to fetch, so one domain can publish several keys at once: one per sending service, or one per rotation. Several selectors on one domain are normal.

The selector is chosen by the service, not by you, and it differs per service. From each service's own docs (checked November 2026): SendGrid uses s1 and s2 (or m1 for the TXT variant), Mailgun pdk1 and pdk2, Postmark a selector ending in pm, Resend resend, Mailtrap rwmt1 and rwmt2, Brevo brevo1 and brevo2, and Mailjet mailjet. The table below shows where each one is published.

There are two ways to find the one a message used:

  • In a received message. Open the message's full headers and read the s= tag of the DKIM-Signature header. In Gmail: next to Reply, click More, then Show original (Google's help page, checked November 2026).
  • On your service's setup screen. The DNS records it asks for contain the selector in the hostname.

DKIM key length and key rotation

Use RSA keys of 2048 bits where your DNS host and service allow it, and rotate keys at least every six months. The first is a SHOULD in RFC 8301, which says signers "MUST use RSA keys of at least 1024 bits" and "SHOULD use RSA keys of at least 2048 bits", and that rsa-sha1 must not be used. RFC 6376 §3.3.3 notes the trade-off: very long keys (4096-bit) might not fit in a 512-byte DNS UDP response. Two of the nine services in the table below, Postmark and Resend, publish 1024-bit keys, per their docs.

Rotation means replacing the key pair on a schedule, so that a stolen or cracked key stops being useful. The six-month rotation advice comes from M3AAWG, an industry group, not a standards body. Its DKIM key rotation best practices (revised April 2018) say keys "should be rotated at least every six months", relaxed from an earlier quarterly cycle.

Selectors make rotation safe, because two keys can live side by side. The usual order: publish the new key under a new selector, switch signing to it, leave the old record in DNS for a while so messages still in transit verify, then remove it.

Who does that for you depends on the service (each service's docs, checked November 2026):

  • Rotates automatically: Mailgun (every 120 days by default, minimum 5), Mailtrap (monthly, per its website), Brevo (with CNAMEs), SendGrid (with automated security on; interval not stated).
  • You trigger it: Postmark, through its Domains API. With your own key at Amazon SES, you rotate.
  • Not rotated or not documented: Resend's docs say its key is not rotated; Amazon SES's Easy DKIM, Mailjet and MailerSend rotation is not documented.

The full row per service is in the next section.

DKIM keys for each sending service

With a sending service you do not generate a DKIM key: you add the DNS records the service shows after you add your domain, then click verify. What differs is how many records you add, whether they are CNAMEs or a TXT, and who holds the key. The table covers nine services, in the order we use across the site.

Service DKIM records Who holds the keys Rotation Key length
SendGrid 2 CNAMEs (s1, s2._domainkey); 1 TXT if automated security is off SendGrid (CNAME) or you (TXT) Automatic with automated security; interval not stated Not documented
Amazon SES 3 CNAMEs (Easy DKIM); 1 TXT (bring your own key) SES (Easy DKIM) or you Easy DKIM: not documented; your own key: you rotate 2048 default, 1024 selectable
Mailgun 2 CNAMEs (pdk1, pdk2._domainkey); 1 TXT manual Mailgun (CNAME) or you (TXT, PEM import) Automatic every 120 days by default (minimum 5) 2048 automatic; 1024 or 2048 manual
Postmark 1 TXT (…pm._domainkey) You publish the public key You trigger it via the Domains API 1024
Resend 1 TXT (resend._domainkey) You publish the public key Not rotated 1024 (2048 not supported)
Mailtrap 2 CNAMEs (rwmt1, rwmt2._domainkey) Mailtrap (CNAME) Monthly, automatic Not documented
Brevo 2 CNAMEs (brevo1, brevo2._domainkey) or 1 TXT Brevo (CNAME) or you (TXT) Automatic with CNAMEs 2048 CNAME; 1024 TXT
Mailjet 1 TXT (mailjet._domainkey) You publish the key Mailjet generates Not documented 2048 default; 1024 or 4096 selectable
MailerSend 2 CNAMEs Not documented Not documented 2048

From each service's own docs and product pages, checked November 2026. "Not documented" means we didn't find it in the vendor's docs. Mailtrap's monthly rotation comes from its website, not its docs. Docs: SendGrid, Amazon SES, Mailgun, Postmark, Resend, Mailtrap, Brevo, Mailjet, MailerSend. Setup steps for each are in our reviews of SendGrid, Amazon SES, Mailgun, Postmark, Resend and Mailtrap.

Two things from the vendor docs trip people up. Brevo's docs say CNAME flattening on its DKIM CNAMEs breaks verification, and Resend's say its CNAME records must not be proxied; Cloudflare recommends DNS-only for records that don't serve web traffic. And the rotation column varies by service: it shows who documents rotation, not what a CNAME implies.

If you run your own mail server instead, you generate the key pair yourself, publish the public half as a TXT record, and set your mail server to sign with the private half. We don't cover the steps here.

How to check your DKIM record

You can check DKIM in three ways: read the result in a received message, query the selector in DNS, or run it through a free third-party checker. A pass means the signature verified against the published key; a fail means it didn't, or the key couldn't be found.

  1. Read Authentication-Results. Send a message to a mailbox you control, open the full headers and look for dkim=pass in the Authentication-Results header, a field defined in RFC 8601. In Gmail, the full headers open from More, then Show original (Google's help page, checked November 2026).
  2. Query the selector in DNS. For the example selector above: dig TXT brisbane._domainkey.example.com +short. You should get back a v=DKIM1; ...; p=... string. If you added a CNAME, the answer follows it to the service's TXT record.
  3. Use a third-party checker. Google's Admin Toolbox has Messageheader, which analyzes a pasted header, and Check MX, which takes an optional DKIM selector. We don't run a checker of our own.

If the lookup returns nothing, the record isn't published at that exact name yet, or your DNS host appended your domain a second time. Both are common and both are in our failure guide.

What happens when DKIM fails

A DKIM failure alone doesn't always get a message blocked, but with a DMARC policy it can lead to spam folder placement or rejection. Under DMARC, a message passes when SPF or DKIM passes with a domain aligned to the From domain (RFC 9989). If DKIM fails and SPF doesn't align either, the domain's DMARC policy decides what happens next.

Common causes: the record is wrong or missing, something changed the signed body in transit, or the selector in the signature doesn't match a published key. The table of errors and fixes is on fix SPF, DKIM and DMARC failures.

Ready to pick a service? Compare the best transactional email services.

DKIM: FAQ

What does DKIM stand for?

DKIM stands for DomainKeys Identified Mail. It is an email authentication method defined in RFC 6376 in which a sending server signs each message with a private key and publishes the public key in DNS, so receivers can verify the message and its signing domain.

What is a DKIM selector?

A DKIM selector is the label in front of ._domainkey in a DKIM record's hostname. It tells the receiver which public key to fetch, so one domain can publish several keys, one per service or per rotation. The s= tag in the DKIM-Signature header carries it. See DKIM selectors.

What is the difference between SPF and DKIM?

SPF checks whether the sending server's IP address is allowed to send for the domain in the envelope sender. DKIM checks a cryptographic signature on the message itself. SPF can fail when mail is forwarded; DKIM usually survives if the message isn't changed. See SPF, DKIM and DMARC explained.

How do I get my DKIM record?

Your sending service generates it. Add your domain in its dashboard and it shows the DNS records, either CNAMEs that point to keys it hosts or a TXT record holding the public key. Add them at your DNS host, then verify. See the per-service table.

How do I set up DKIM for email?

Two steps: add your sending domain in the service's dashboard, then publish the DNS records it shows and click verify. If you use Cloudflare, check the service's docs on proxying and CNAME flattening. You don't generate the key yourself unless you run your own mail server. See the per-service table.

Why is my message blocked due to DKIM failure?

Usually the DKIM record is missing or wrong, the signed content was changed in transit, or the selector doesn't match a published key. A DKIM failure alone doesn't always block mail, but a DMARC policy can turn it into rejection. The fixes are on fix SPF, DKIM and DMARC failures.

Do I need DKIM if I have SPF?

Yes. DMARC passes when SPF or DKIM passes with an aligned domain, and forwarding often breaks SPF while a DKIM signature usually survives. Google and Yahoo also ask bulk senders to set up both. See SPF, DKIM and DMARC explained.

Can I have more than one DKIM record on a domain?

Yes, one per selector. Each sending service signs with its own selector, so a domain that uses two services normally has two DKIM records at different hostnames. They don't conflict. Only the selector in each message's DKIM-Signature header is looked up. See DKIM selectors.