How to Set Up a DKIM Email Record

DKIM is a DNS task: your provider makes the key, you publish the TXT record. Here is how to find it, add it, and check it worked.

You have been told to set up DKIM. The good news is that it is mostly a DNS task. Your email provider usually makes the key. Your job is to copy one TXT record into your DNS. This guide walks you through finding that record, adding it, and checking it worked.

What DKIM is

DKIM lets the owner of a signing domain claim responsibility for a message by tying the domain to it. It does this with a cryptographic signature. The sending server signs the message with a private key. The receiver checks the claim by querying the signer's domain in DNS for the matching public key. If the key fits the signature, the signing domain has taken responsibility for the message. The message has also not been changed since it was signed.

Why Gmail and Yahoo require it

Gmail's guidelines say receiving servers use DKIM to verify that the domain owner actually sent the message. Gmail requires all senders to set up SPF or DKIM on their sending domains. Bulk senders need both, plus DMARC. Gmail also requires a DKIM key of 1024 bits or longer for mail to personal Gmail accounts.

Yahoo's FAQ says DKIM lets senders digitally sign emails sent to Yahoo Mail accounts. It also lets Yahoo verify the message has not changed since the signature was added. Yahoo's guide says senders should authenticate every email with DKIM.

Gmail's guidelines say authenticated messages are less likely to be rejected or marked as spam. DKIM alone does not promise inbox placement. It removes one clear reason to be blocked.

What a DKIM record looks like

A DKIM record is a DNS TXT record. It lives at a hostname built from two parts: a selector you choose, plus your domain. A common form looks like selector._domainkey.example.com. The selector is part of the hostname, which is why one domain can have several DKIM records at once. You might rotate keys, or sign mail from different systems, each with its own selector.

The record value is a string of tag=value pairs:

  • v=DKIM1 says this is a DKIM key record.
  • k=rsa names the key type. Most records use RSA.
  • p= holds the public key itself. This is the long string of letters and numbers. It is the key receivers query for.

Other tags exist, but those three carry the weight. When someone asks what your DKIM record is, they mean this TXT record.

How to find your DKIM record

In the common case, your provider already made the key pair. Gmail's guidelines say if you use an email service provider, verify that they authenticate your domain's email with SPF and DKIM.

  • In a typical ESP, look for a section named domain authentication, email security, or sending domains. Enabling DKIM there shows the hostname and value to copy.
  • At your domain host, check the DNS settings for any TXT record on a hostname containing _domainkey. If one is there, DKIM may already be published.

To look up an existing record, run a DNS TXT query on the selector hostname. A lookup tool or the dig command works. Query selector._domainkey.example.com for TXT, and the record comes back if it exists.

How to create a DKIM record

There are two paths.

If your provider generates the key, enable DKIM in their panel and copy the values they show. This is the better path for almost everyone. The provider keeps the private key on its sending servers and signs your mail for you.

If you must generate the key pair yourself, mind the key length. DKIM's standard says signers must use RSA keys of at least 1024 bits for long-lived keys. The private key stays on the sending server and never goes in DNS. Only the public key goes into the TXT record.

Adding the record at your domain host takes three fields:

  • The hostname, which is the selector plus ._domainkey. Some hosts want the full hostname. Others want just the selector part and add the rest for you. Check what the host shows in the preview before saving.
  • The value, which is the full tag string including v=, k=, and p=.
  • The TTL, which you can leave at your host's default.

A DKIM record wizard or generator can build the tag string for you if you are making a key by hand. It cannot sign your mail. The private key still has to live on the server that sends.

How to check it worked

Send yourself a signed message and open the raw source. Look for the DKIM-Signature header. Two tags in it matter most: d= is the signing domain, and s= is the selector. Then run a DNS TXT query on the selector hostname, the s= value followed by ._domainkey. and the d= value, to confirm the record answers.

Mail usually travels through relays that do not change the message content, so the signature stays intact. That is why the signature can still be checked after the message passes through relays.

What DKIM does not do on its own

DKIM separates the identity of the signer from the claimed author of the message. A message can carry a valid signature from any domain, even a domain absent from the From: header. That is why DMARC exists. DMARC requires alignment between the signing domain and the From: header domain, and gives a pass if a DKIM-authenticated identifier aligns with the author domain.

Gmail's guidelines say DMARC tells receiving servers what to do with messages that don't pass SPF or DKIM. Google Workspace Help says to set up DKIM and SPF before setting up DMARC. So DKIM is your next step toward DMARC, not the last one. DMARC setup is its own job, and this guide stops here.

Troubleshooting the common failures

  • Key too short. Gmail requires 1024 bits or longer for personal accounts. Check the key length in your provider's settings, or regenerate the key.
  • Record split across multiple TXT strings. DNS limits string length, so long keys get split into quoted chunks. If your host joins them wrong, or drops a chunk, the key is broken. Make sure the full value is present as one record.
  • Wrong hostname. Some domain hosts append your domain name to whatever you type. If you enter the full hostname, the record ends up at selector._domainkey.example.com.example.com. Query the hostname to see where the record really landed, and fix the entry so it appears once.
  • Gmail error 5.7.30 or 4.7.30. Gmail's FAQ says error code 4.7.30 means DKIM authentication didn't pass, and 5.7.30 means the message was blocked because it didn't pass DKIM authentication. These point at DKIM, so recheck the selector hostname, the published key and the signing setup.

One question people also ask

Some guides mention a DKIM "policy record", but what receivers actually query is the key record at the selector hostname. It is not the same thing as DMARC.

Once DKIM passes, finish the sender basics. If you send bulk mail, the one-click unsubscribe headers Gmail and Yahoo ask for are part of the same checklist.

Sources

Filed

More filed under SPF and DKIM

  • How to find all DNS records for a domain
  • How to Set Up a DKIM Record for Your Domain
  • What a DKIM record is and what each part does
  • Why Your Email Failed SPF and What to Do
  • Can a Domain Have Multiple SPF Records?
  • What It Means When a Domain Has No SPF Record
  • How to Set Up an SPF Record for Your Domain
  • What SPF Email Authentication Checks and Why It Matters
  • How to Set Up a Gmail SPF Record
  • What an SPF Record Is and Where It Goes in DNS
  • SPF record syntax, tag by tag
  • What an SPF Record Is and How to Read Yours