What Is DKIM?
DKIM (DomainKeys Identified Mail) adds a digital signature to outgoing email, generated with a private key and verified by receiving servers using a public key published in a DNS TXT record. If the signature checks out, the receiver knows the message's key fields were not changed after it was signed, which helps prevent spoofing and improves deliverability.
How DKIM works
- The sending mail server generates a cryptographic key pair: a private key kept secret on the server, and a public key published in DNS.
- When an email is sent, the server creates a hash of selected headers and the message body, then encrypts that hash with the private key to create a signature.
- The signature and the key's selector name are added to a
DKIM-Signatureheader on the outgoing message. - The receiving mail server looks up the public key at a DNS TXT record named using the selector and domain, such as
default._domainkey.example.com. - It uses the public key to verify the signature. A match means the signed parts of the message were not altered after signing.
What a DKIM DNS record looks like
default._domainkey.example.com. IN TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSq..."
The v=DKIM1 tag identifies the record version, k=rsa names the key type, and p= holds the public key itself, usually a long base64 string. The subdomain before _domainkey is the selector, which lets a domain run more than one DKIM key at a time, for example one per sending service.
DKIM compared to SPF and DMARC
| Mechanism | What it checks | What it cannot do alone |
|---|---|---|
| SPF | Whether the sending server's IP is authorized for the domain | Detect if message content was altered |
| DKIM | Whether the signed content matches the signature (integrity) | Decide what receivers should do if it fails |
| DMARC | Combines SPF and DKIM results and tells receivers what action to take | Work without at least one of SPF or DKIM passing |
DKIM survives forwarding better than SPF in many cases, since it travels with the message itself rather than depending on which server relays it, though some mailing list or forwarding setups can still break a DKIM signature by modifying the message.
Setting up DKIM
Most email hosting providers and transactional email services (such as the provider behind your website's contact form or marketing emails) generate the key pair for you and give you a single DNS TXT record to add. Typical steps are:
- Enable DKIM signing in your email hosting or sending service's control panel.
- Copy the exact selector and public key TXT record it provides.
- Add that TXT record at your DNS provider, matching the name and value precisely.
- Wait for DNS propagation, then use the service's built-in checker or a DNS lookup to confirm the record is visible.
- Send a test email to a mailbox that shows authentication results, such as Gmail, and check the message's "Show original" view for a DKIM "pass".
Checking a DKIM record
dig TXT default._domainkey.example.com +short
If nothing is returned, either the selector name is wrong or the record has not been published yet. Each sending service you use (your website host, a marketing platform, a CRM) may need its own selector and key, so a domain commonly has more than one DKIM record active at once.
Frequently asked questions
What does DKIM stand for?
DKIM stands for DomainKeys Identified Mail. It is an email authentication method that adds a cryptographic signature to outgoing messages so receivers can verify they were not altered in transit.
Is DKIM the same as SPF?
No. SPF checks whether the sending server's IP address is authorized for the domain, while DKIM checks whether the message content matches a cryptographic signature. They check different things and are meant to be used together.
Do I need DKIM if I already have SPF set up?
Yes, DKIM is still worth setting up. SPF alone does not verify message integrity and can fail entirely when email is forwarded, while DKIM adds a layer that often survives forwarding and strengthens DMARC results.
Why is my email failing DKIM verification?
Common reasons include a missing or incorrect DNS TXT record, a selector name that does not match what the sending server used, or the message being modified after signing by a mailing list, forwarder or some security gateways.
Can I have more than one DKIM record?
Yes. Each DKIM record uses a unique selector name, so a domain can publish several records at once, typically one for each service that sends email on its behalf, such as the website host, a marketing tool and a helpdesk.
Does DKIM stop spam from reaching my inbox?
Not directly. DKIM proves a message's signed content was not altered and that it was actually signed by keys controlled by the claimed domain; it does not evaluate whether the message is spam. Spam filtering relies on DKIM results as one of several signals, alongside SPF, DMARC and content analysis.
Related topics
- What Is an SPF Record? Email Hosting
- What Is a DNS TXT Record? Domains & DNS
- Email Deliverability Basics Email Hosting
- What Is an Email Server? Email Hosting
- What Is DNS (Domain Name System)? Domains & DNS