DNS and authentication

How to set up DKIM

Short answer

To set up DKIM, have your email service generate a key pair, then publish the public key in DNS at selector._domainkey.yourdomain, either as a TXT record or as a CNAME to a key the service hosts. The service signs every message with the private key, and receivers check the signature against your record. Use 2048-bit keys where possible, set up DKIM for every service that sends as you, and confirm DKIM=PASS with your domain in a test message.

Last checked 16 November 2026

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

  1. Your email service signs selected headers and the body of each message with a private key.
  2. 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=...
  1. The receiver reads d=acme.com (the signing domain) and s=s1 (the selector), and fetches the public key from s1._domainkey.acme.com.
  2. 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

  1. Find the DKIM settings in each service that sends as your domain. They are usually under “domain authentication”, “sender authentication” or “domains”.
  2. Generate or request the key. Choose 2048 bits if offered.
  3. Copy the record(s) the service gives you: a host name and a value.
  4. Add them in your DNS panel. If your panel appends the domain automatically, enter only s1._domainkey, not s1._domainkey.acme.com.
  5. Verify in the service. Most have a “verify” button that checks the record is live.
  6. 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.com for Google Workspace
  • s1._domainkey.acme.com for your app’s email service
  • k1._domainkey.acme.com for 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:

  1. Publish a new key under a new selector (s2).
  2. Switch the service to sign with s2.
  3. Wait a few days so mail in flight can still be verified with s1.
  4. 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.

Questions

What is a DKIM selector?

A label that tells receivers which key to fetch. The signature carries s=selector and d=domain, and the receiver looks up selector._domainkey.domain. Selectors let one domain have many keys, one per service or per rotation.

Should I use a 1024 or 2048 bit DKIM key?

2048. RFC 8301 requires at least 1024 bits and recommends 2048. Google also recommends 2048-bit keys where your provider supports them.

Why is my DKIM record a CNAME instead of a TXT?

Many email services host the key themselves and ask you to point a CNAME at it. That lets them rotate keys without you editing DNS. The receiver follows the CNAME to a normal DKIM TXT record.

Does DKIM pass mean DMARC passes?

Only if the signing domain (d=) aligns with the From domain. A service that signs with its own domain passes DKIM but does not help DMARC.

Can I have more than one DKIM record?

Yes. Unlike SPF, each DKIM key lives at its own selector, so you can have one per service and several during a rotation.

Related

Send with someone on your side.

Unlimited domains on every plan, a person before any block, and 3,000 emails a month free. Tell us what you send and we set you up within one business day.