What a DKIM record does

DomainKeys Identified Mail (DKIM) lets a receiving mail system check whether a message was signed by a sender authorized to use a particular domain and whether signed parts of the message changed in transit. The sending system signs mail with a private key. You publish the matching public key in DNS so receivers can check that signature. The private key stays with the system that sends and signs the mail; it must never be placed in a DNS record.

A DKIM signature identifies a signing domain with a d= value and a selector with an s= value. Together, these tell a receiver where to look for the public key. For example, a signature containing d=example.com and s=mail1 points to a DNS record at mail1._domainkey.example.com. The selector is a label used to find a key, not a password or a secret.

Choose a selector you can manage

A useful selector is short, recognizable, and specific enough to distinguish one signing key from another. Names such as mail1 or provider-a can work. If several services send mail for your domain, give each service its own selector rather than making unrelated systems share one private key. That makes it easier to replace a key or stop using a service without disrupting the others.

There is no need to put sensitive information in a selector: anyone can see the DNS name. Record internally which service uses each selector, who manages its key, and whether it is still active. You can also plan for rotation by using a new selector when you create a replacement key. A selector only helps if the sending service is configured to sign with that same value; publishing a record alone does not enable DKIM signing.

Publish the public key as a TXT record

Generate the key pair through your mail provider or signing software, following its setup instructions. The provider may supply a complete DNS record rather than asking you to build one. For a typical RSA DKIM key, the TXT value has the form v=DKIM1; k=rsa; p=PUBLIC_KEY. The p= value contains the public key material supplied for DNS. Do not substitute the private key, and do not copy explanatory labels or line breaks into the value unless your DNS provider specifically requires that format.

Create the record at the hostname for your selector under _domainkey. In a DNS editor for example.com, you might enter mail1._domainkey as the host; another editor might require the full name mail1._domainkey.example.com. Check how that editor handles zone names so you do not accidentally create mail1._domainkey.example.com.example.com. Some providers split a long TXT value into quoted pieces; that can be normal if DNS returns them as one value. Follow the format your mail service specifies.

Check both DNS and a signed message

After saving the record, query the full hostname for a TXT record and confirm that the returned public key matches the one your signing service expects. If nothing appears, check the selector spelling, the _domainkey label, and whether you edited the authoritative DNS zone. DNS caches may continue to serve an earlier answer until its time to live expires, so a recent change may not be visible everywhere at once.

Then send a test message through the service that will use the key. Inspect its authentication results or DKIM-Signature header to confirm that it was signed with the intended d= domain and s= selector, and that DKIM verification passes. A visible DNS record does not prove that the sender is using the corresponding private key. If you use DMARC, also check whether the DKIM signing domain aligns with the domain in the visible From address; a passing DKIM signature by itself does not guarantee DMARC alignment.

Rotate keys without interrupting verification

When replacing a signing key, create a new key pair and publish its public key under a new selector. Confirm that the new record is available before switching the sending service to sign with it. Test a message signed with the new selector, then keep the old record while previously sent messages might still be checked or delivered. Once the old key is no longer in use and your transition period has passed, remove its DNS record.

If a service supplies its own selector and rotation process, follow that process instead of changing names independently. Keep private keys restricted to the signing systems that need them, and remove records and access associated with services you no longer use. Clear selector names and a simple record of which system owns each key make future troubleshooting and rotation much easier.

Back to category ↗