Quick answer: DKIM (DomainKeys Identified Mail) adds an invisible cryptographic signature to every email you send and publishes the matching public key in your domain's DNS. The receiving server checks that signature and confirms two things: the message really came from your domain, and nobody changed it on the way. Unlike SPF, the signature survives forwarding.
No cryptography background is needed for the rest of this guide. It covers what DKIM does, why the selector confuses everyone, how to publish the record, and the mistakes that quietly break it.
The problem SPF cannot solve
SPF is the guest list that tells mail servers which machines may send as your domain. It works, but it has one hole. When someone forwards your email, it arrives from their server, which is not on your list, so SPF fails. Mailing lists, alumni addresses and aliases that redirect to several people all break SPF this way.
DKIM asks a different question. Instead of "did this come from an approved server", it asks "was this message signed by the domain owner, and has it been changed since?" Forward the message a hundred times and the signature still checks out. That is why you want both.
DKIM in plain English
Think of a wax seal on a letter. Anyone can see the seal is yours, because only you have the ring, and a broken seal means the letter was opened.
DKIM does the same with math. Your mail server holds a private key that never leaves it. For every message, the server calculates a signature with that key and adds it in a hidden header. Your domain publishes the matching public key in DNS where anyone can read it. A public key can only verify signatures, never forge them. That asymmetry is the whole trick. DKIM is defined in RFC 6376, with the cryptography rules updated in RFC 8301.
The selector: the part that confuses everyone
With SPF you look up your domain and find the record. DKIM has no fixed address. The public key lives at a name that includes a label the sender chose, called a selector:
selector1._domainkey.yourcompany.com
The _domainkey part is fixed. The selector could be google, pm, k1 or s2026a. One domain often sends through several services, and each needs its own key, so each gets its own selector. That lets you rotate or shut off one service without touching the others.
The catch is that DNS cannot list every name under a branch. If you do not know the selector, you cannot look the key up.
What the numbers say
A February 2026 scan of about 5.5 million domains from the Tranco top sites list, reported by DMARCguard, found DKIM on 22.7 percent of domains, compared with 56.0 percent for SPF and 30.4 percent for DMARC. Google and Yahoo have enforced authentication rules for bulk senders since February 2024, and Microsoft followed in May 2025 for Outlook.com, Hotmail.com and Live.com. All three expect DKIM.
How it works, step by step
- Your server selects some headers (From, Subject, Date, To) plus the body, hashes them, and encrypts the result with the private key.
- It attaches the result as a
DKIM-Signatureheader, which names the signing domain (d=), the selector (s=), the signed headers (h=), the body hash (bh=) and the signature (b=). - The message travels, possibly through relays and forwarders.
- The receiver reads
d=ands=and looks upselector._domainkey.domainin DNS. - It recalculates the hash, checks it against the signature using your public key, and gets a yes or no.
What DKIM does not do
- It does not stop spoofing alone. A signature can verify while the visible From address belongs to someone else. Only DMARC forces the signing domain to match the address the reader sees.
- Signatures can be replayed. A signature has no timestamp and no recipient binding, so an attacker who captures a signed message can resend it unchanged and it still passes. A 2025 campaign did this with a genuine Google security alert.
- Changes to the body break it. Mailing list footers and link-rewriting gateways alter the body, so the signature fails even though nothing was malicious.
Reading a DKIM record
v=DKIM1; k=rsa; h=sha256; p=MIIBIjANBgkq...
This is a DKIM record using an RSA key and SHA-256, followed by the public key. It is clean. Two quietly broken versions are worth knowing:
t=ymeans testing mode is still on, so receivers ignore your failures. You are signing everything and getting no benefit. This is one of the most common findings.p=with nothing after it means the key is revoked. If you still sign with that selector, every message is failing DKIM right now.
How to find your selector
- Read it from a message you sent. Send yourself an email, open the raw source (in Gmail, the three dots then Show original) and read the
s=tag in the DKIM-Signature header. This is the only method that cannot be wrong. - Check your provider's setup page. The DNS hostname they gave you contains it, ending in
._domainkey. - Try common ones. Google Workspace uses
google, Microsoft 365 usesselector1andselector2, SendGrid usess1ands2, and Mailchimp usesk1.
Publishing your DKIM record
- List every service that sends email as you: main mail, marketing, transactional, CRM, helpdesk, invoicing.
- Generate the key inside each provider. Choose 2048-bit RSA.
- Publish the record they give you. If it is a CNAME, keep it as a CNAME, because the provider can then rotate the key without touching your DNS. Never copy it into a TXT record.
- Watch the 255 character limit. A 2048-bit key is about 392 characters and must be split into chunks within one record. Some DNS panels silently truncate it, so mail still sends but every receiver rejects the signature.
- Switch signing on in your provider, then remove
t=yonce signatures verify. - Test it, and send yourself a message to confirm Gmail shows DKIM as PASS for your own domain.
What a strong setup looks like
- Every sending service signs, including invoices and order confirmations.
- Keys are 2048-bit RSA.
- Each service has its own selector, with versioned names such as
s2026a. - No
t=yanywhere, and no revoked key still in use. - The signing domain aligns with your From address.
- Keys rotate every 6 to 12 months.
To rotate safely, publish the new key at a new selector, wait for the old TTL to expire, switch signing to the new selector, then revoke the old key by publishing it with an empty p=. Do not delete it.
The most common mistakes
- The key was published but signing was never switched on.
- Testing mode left on.
- A truncated 2048-bit key.
- 1024-bit keys nobody has revisited.
- A CNAME turned into a TXT copy that breaks on rotation.
- One selector shared across every platform.
- Signing with the provider's domain instead of yours, so DMARC alignment fails.
- Set up once and never checked again.
How SPF, DKIM and DMARC fit together
- SPF asks whether this server is allowed to send for the domain. It breaks on forwarding.
- DKIM asks whether the domain owner signed this message and whether it is unaltered. It survives forwarding.
- DMARC says what to do when the others fail, and checks that the authenticated domain matches the visible From address.
DMARC passes if either SPF or DKIM passes and aligns, which is the reason to publish both.
Frequently asked questions
What is a DKIM selector? A label chosen by the sender that identifies which key to use. It appears in the DNS name as selector._domainkey.domain and in the s= tag of the message's signature.
Why can't a checker find my DKIM record automatically? DNS cannot list names under a branch, so a tool can only guess common selectors. A blank result means the guesses missed, not that no key exists.
Should keys be 1024-bit or 2048-bit? Use 2048-bit. Shorter keys still verify at most receivers, but they fall below current recommendations and security gateways treat them as weak.
Does DKIM stop spoofing completely? No. A signature can verify while the visible From address is forged, and signed messages can be replayed. DMARC ties the signature to the address the recipient sees.
Do I need DKIM if I already have SPF? Yes. SPF breaks when a message is forwarded and DKIM does not, so publishing both keeps legitimate mail delivering.
Is DKIM free? Yes. Your mail provider generates the key at no cost and you publish one DNS record on a domain you already own.
Check your own domain
I run Email Verifyer API, which has a free DKIM record checker along with SPF, DMARC, MX, MTA-STS and BIMI lookups. Disclosure: this is my own project. The DKIM checker can try about thirty common selectors if you leave the selector field blank, and it flags 1024-bit keys, revoked keys and testing mode. Any DNS lookup tool can confirm the same details.
This is a condensed version of my longer Medium guide: DKIM Explained: The Invisible Signature That Proves Your Email Is Really Yours.
About the author
- About cyber security, investigations, and more
Comments
Join the discussionNo comments yet. Be the first to comment.
