DKIM

What Is DKIM? DomainKeys Identified Mail Explained

DKIM adds a cryptographic signature to every message, and receivers verify it with a public key in your DNS. This guide covers the DKIM-Signature header, selectors and key records, key sizes and Ed25519, key rotation, forwarding and mailing lists, and how DKIM alignment makes DMARC work.

By MailConfig.pro TeamPublished 6 min read

On this page
  1. How DKIM works
  2. The DKIM-Signature header
  3. Selectors and the key record
  4. Finding your selector
  5. Key sizes and algorithms
  6. Rotating DKIM keys
  7. DKIM, forwarding and mailing lists
  8. DKIM and DMARC alignment
  9. Seeing which DKIM signatures pass

DKIM (DomainKeys Identified Mail) is an email authentication method that adds a cryptographic signature to each message. The sending server signs selected headers and the body with a private key, and puts the signature in a DKIM-Signature header. The receiving server fetches the matching public key from the sender's DNS and checks the signature. If it verifies, the receiver knows two things: the domain in the signature took responsibility for the message, and the signed parts were not changed on the way. DKIM is defined in RFC 6376.

How DKIM works

  1. Signing. Your mail server or email service hashes the body and a chosen list of headers, then signs the result with the private key. The private key never leaves the sending system.
  2. Publishing. You publish the public key as a TXT record in your DNS, under a name made from a selector and your domain.
  3. Verifying. The receiver reads the d= (domain) and s= (selector) tags from the signature, fetches the key at s._domainkey.d, recomputes the hashes and checks the signature. The result is pass, fail, neutral, temperror, permerror or none for an unsigned message.

Unlike SPF, which checks the IP address of the connecting server, DKIM is tied to the message itself. That is why it survives forwarding when SPF doesn't.

The DKIM-Signature header

A signed message carries a header like this (shortened):

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com;
  s=s2026; t=1796380000; h=from:to:subject:date:message-id;
  bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=;
  b=AuUoFEfDxTDkHlLXSZEpZj79LICEps6eda7W3deTVFOk...
Tag Meaning
v=1 DKIM version
a= Algorithm: rsa-sha256, or ed25519-sha256
d= The signing domain, which takes responsibility for the message
s= The selector, which tells the receiver which key to fetch
c= Canonicalization for header/body: simple or relaxed. relaxed tolerates whitespace and header-case changes
h= The signed headers. From must always be one of them
bh= Hash of the body
b= The signature itself
t=, x= Signing time and optional expiry

An optional l= tag limits how much of the body is signed. Avoid it: anyone can append content after the signed length without breaking the signature.

Selectors and the key record

The selector lets one domain have many keys at the same time: one per email service, one per mail server, or an old and a new key during rotation. The key for selector s2026 on example.com lives here:

TXTs2026._domainkey.example.com
v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq8Jx...
  • v=DKIM1: optional, but if present it must come first.
  • k=: key type, rsa (the default) or ed25519.
  • p=: the public key, base64-encoded. An empty p= means the key has been revoked.
  • t=y: the domain is testing DKIM. t=s requires the d= domain and the i= identity in signatures to match exactly, without subdomains.

A 2048-bit RSA key is longer than the 255-character limit of a single TXT string, so it is split into several strings that receivers join back together. Most DNS panels do this automatically. If yours doesn't, paste the value in quoted chunks.

Many email services ask you to publish a CNAME instead, for example s1._domainkey.example.com pointing to a key they host. That lets them rotate keys for you. Remove those CNAMEs when you stop using the service: a selector that points to a domain someone else can register is a way to hijack your authentication.

Finding your selector

There is no way to list every selector a domain has; DNS only answers for names you ask about. To find yours, look at a message you sent: the s= and d= tags in its DKIM-Signature header give the selector and domain. The email header analyzer extracts them from pasted headers. You can also send a message to the free deliverability test, which reports the DKIM result and the signing domain as our server saw them.

Key sizes and algorithms

  • RSA 2048 bits is the standard choice. RFC 8301 says signers must use keys of at least 1024 bits and should use at least 2048, and it forbids signing with rsa-sha1.
  • RSA 4096 bits is allowed, but the key no longer fits comfortably in DNS and gains little in practice.
  • Ed25519 (RFC 8463) gives short keys and signatures. Not every receiver verifies it yet, so it is used as a second signature next to an RSA one.

The DKIM key generator creates RSA-2048, RSA-4096 or Ed25519 key pairs in your browser. The private key is never sent to us. Generating a key doesn't make anything sign with it: you still configure the private key in your mail server or service.

Rotating DKIM keys

A key that has been in use for years is a larger risk if it ever leaks. Rotate on a schedule, for example every six to twelve months, and immediately after a suspected compromise:

  1. Generate a new key pair and publish the public key under a new selector.
  2. Wait until the record is visible, then switch the sending system to the new selector.
  3. Keep the old key published for a few days, so mail already in transit still verifies.
  4. Revoke the old key by publishing the old selector with an empty p=, or remove it.

DKIM, forwarding and mailing lists

DKIM keeps working when a message is forwarded unchanged, because the signature travels with the message. It breaks when an intermediary changes what was signed: a mailing list that adds [list-name] to the subject or a footer to the body, or a security gateway that rewrites links. ARC (RFC 8617) lets such intermediaries record the authentication results they saw before they modified the message, and some receivers take that into account.

DKIM and DMARC alignment

A valid DKIM signature isn't enough for DMARC. The signing domain (d=) must also align with the domain in the From: header (RFC 9989, section 4.4). Many email services sign with their own domain by default, d=mailprovider.example. That passes DKIM but fails DMARC alignment for your domain. The fix is to set up custom DKIM in the service, so it signs with d=example.com or a subdomain of it.

Because DKIM survives forwarding, an aligned DKIM signature is the most reliable way to pass DMARC. How DMARC uses SPF and DKIM together is covered in the DMARC guide.

Seeing which DKIM signatures pass

DMARC aggregate reports list every DKIM signature receivers saw on your mail: the domain, the selector and whether it passed. They are the easiest way to find a service that signs with its own domain instead of yours, or a selector you forgot. MailConfig.pro's DMARC monitoring shows each sending source with its DKIM and SPF alignment, so you can see which services still need custom DKIM before you enforce DMARC.

Frequently asked questions

Where do I find my DKIM selector?

Open a message you sent, view its full headers and look for the DKIM-Signature header. The s= tag is the selector and d= is the signing domain. The key lives at s._domainkey.d in DNS.

What DKIM key size should I use?

RSA 2048-bit. RFC 8301 requires at least 1024 bits and recommends 2048. Ed25519 keys are smaller and faster but not every receiver verifies them yet, so they are used alongside an RSA signature, not instead of it.

How often should I rotate DKIM keys?

On a regular schedule, for example every six to twelve months, and immediately if a private key may have leaked. Rotate with a new selector so the old and new keys can overlap.

Does DKIM pass when an email is forwarded?

Usually yes, if the forwarder doesn't change the signed headers or the body. Mailing lists that add a subject tag or a footer break the signature.

References

dkimemail authenticationselectorkey rotationalignment

DMARC

What Is DMARC? How Email Authentication Fits Together

DMARC is a DNS record that ties SPF and DKIM to the domain in the visible From address, states what receivers should do with mail that fails, and requests reports. This guide covers alignment, the record syntax, policies, reporting and what happens when a domain has no record.

· 10 min read

SPF

What Is SPF? Sender Policy Framework Explained

SPF is a DNS TXT record that lists which servers may send mail using your domain in the envelope sender. This guide covers how a receiver evaluates it, every mechanism and qualifier, the lookup limits, the difference between -all and ~all, and why SPF alone does not stop From spoofing.

· 6 min read

DMARC

How to Identify Unknown Senders in DMARC Aggregate Reports

A step-by-step method for the unfamiliar IP addresses in your DMARC aggregate reports: which XML fields matter, how to map an IP to a service with PTR, RDAP and ASN, how to separate legitimate senders from spoofing, and how to fix SPF and DKIM alignment.

· 7 min read

DNS security

SPF Hijacking: How Dangling CNAMEs and Typos Let Spoofing Pass DMARC

Some spoofed mail passes DMARC because attackers took over a name your DNS still trusts: a CNAME to an expired domain, a mistyped include, or a CIDR typo. How the takeover works, how to spot it in DNS and in DMARC aggregate reports, and how to close it.

· 8 min read