To set up DKIM, generate a key pair in your email service, publish the public key in DNS at selector._domainkey.yourdomain, and turn signing on. From then on, the service adds a DKIM-Signature header to every message, and the receiving server uses your DNS record to verify it. Do this for every service that sends mail as your domain.
DKIM (DomainKeys Identified Mail) is defined in RFC 6376.
How DKIM works
- Your email service signs selected headers and the body of each message with a private key.
- It adds a header such as:
DKIM-Signature: v=1; a=rsa-sha256; d=acme.com; s=s1;
h=from:to:subject:date; bh=...; b=...
- The receiver reads
d=acme.com(the signing domain) ands=s1(the selector), and fetches the public key froms1._domainkey.acme.com. - If the signature matches, DKIM passes. If the message was changed in transit, it fails.
Because the signature travels inside the message, DKIM usually survives forwarding, which SPF does not.
Step by step
- Find the DKIM settings in each service that sends as your domain. They are usually under “domain authentication”, “sender authentication” or “domains”.
- Generate or request the key. Choose 2048 bits if offered.
- Copy the record(s) the service gives you: a host name and a value.
- Add them in your DNS panel. If your panel appends the domain automatically, enter only
s1._domainkey, nots1._domainkey.acme.com. - Verify in the service. Most have a “verify” button that checks the record is live.
- Send a test to Gmail, choose Show original, and confirm DKIM says PASS with your domain.
What a DKIM record looks like
As a TXT record holding the key:
s1._domainkey.acme.com. TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
| Tag | Meaning |
|---|---|
v=DKIM1 |
Version; if present it must be first |
k=rsa |
Key type; rsa is the default |
p= |
The public key, base64. Empty means the key is revoked |
t=y |
Testing mode; receivers must not treat mail differently because of it |
As a CNAME pointing at a key your provider hosts:
abc123._domainkey.acme.com. CNAME abc123.dkim.example-provider.com.
The CNAME form is common with email APIs. The provider can rotate the key behind it without you touching DNS.
Selectors
The selector is just a name you or the provider pick. It lets one domain hold many keys:
google._domainkey.acme.comfor Google Workspaces1._domainkey.acme.comfor your app’s email servicek1._domainkey.acme.comfor your newsletter tool
You can find which selector a message used by reading the s= tag in its DKIM-Signature header. To look up the key:
dig +short TXT s1._domainkey.acme.com
Key size: 1024 vs 2048 bits
RFC 6376 originally required signers to use at least 1024-bit keys. RFC 8301 updated it: signers must use at least 1024 bits and should use at least 2048, and rsa-sha1 must no longer be used. Google’s sender guidelines require 1024 bits or longer for mail to Gmail and recommend 2048.
A 2048-bit public key is longer than the 255-character limit of a single TXT string. Most DNS panels split it automatically; if yours does not, enter it as two quoted strings in the same record, which receivers join together.
Rotating keys
Rotating limits the damage if a private key leaks. With a TXT setup:
- Publish a new key under a new selector (
s2). - Switch the service to sign with
s2. - Wait a few days so mail in flight can still be verified with
s1. - Revoke the old key by setting
p=to empty, then delete it later.
With a CNAME setup, the provider rotates the key for you.
DKIM and DMARC alignment
DKIM passing is not enough on its own for DMARC. The d= domain must align with your From domain: an exact match under strict alignment, or the same organizational domain under relaxed alignment (RFC 7489). Many tools sign with their own domain (d=example-provider.com) until you add custom DKIM records, so check d= in your test message. Then set up DMARC.
Set it up for every sender, not just one
DKIM is per service. Setting it up in Google Workspace does nothing for mail your CRM, helpdesk or app sends as your domain. Each service signs with its own key, at its own selector, and needs its own records in your DNS.
A good way to find the services you forgot is a DMARC record with a rua address. Its aggregate reports list every source sending as your domain and whether DKIM passed for each. Any source with DKIM failing or signed by another domain needs custom DKIM set up in that tool. Once every legitimate source signs with your domain, you can move DMARC toward enforcement with confidence.
Troubleshooting
| Symptom | Likely cause |
|---|---|
dkim=none |
Signing is not turned on, or the service is not set up for your domain |
dkim=fail (no key) |
Record missing, wrong host name, or not propagated yet |
dkim=fail (body hash did not verify) |
Something changed the message after signing, such as a footer added by a gateway |
dkim=pass with another domain |
The service signs with its own domain; add custom DKIM |
Mailcandor and DKIM
When you add a domain, Mailcandor gives you three DKIM CNAME records. Once they resolve, every message is signed with your domain, so DKIM aligns for DMARC. Our free tools check any selector, and the SPF, DKIM and DMARC guide covers the other two records.