The short answer

To create DKIM for your domain, you publish a key that your sending service gives you, then let that service sign your mail. Four steps, in this order:

  1. Get the key and selector from the service that sends your mail.
  2. Publish one record in DNS under selector._domainkey.
  3. Switch signing on at that service.
  4. Send a test message and read its headers.

Usually the sending service makes the key; you only publish it.

What DKIM does

DKIM is defined in RFC 6376, an IETF standards-track document. The sending system signs each message with a private key. The matching public key is published in DNS; the receiver looks it up and checks the signature.

That check shows whether the message was signed for the domain and whether it was changed after signing. It is not a promise of inbox placement and not a spam verdict, and a failed signature does not by itself force a receiver to reject a message.

Where the key comes from

The service that signs your mail usually generates the key pair and shows you the selector and the record to publish. Look in its admin settings, often under email authentication or DKIM, and follow its own instructions.

List every place that sends mail as your domain: staff mailboxes, a newsletter tool, an invoicing system, website forms. Each of them usually has its own selector and record, taken from that service.

If you run your own mail server, generate a key pair with its tools. Keep the private key on the server and protect it; publish only the public part in DNS.

The selector and the DNS record

RFC 6376 puts keys under a subdomain named _domainkey. The selector (s=) and the signing domain (d=) in the message's DKIM-Signature header give the name to look up: for selector s1 and domain example.com, the record is at s1._domainkey.example.com. The record type is TXT. Selectors let a domain have several keys at the same time.

The value looks like v=DKIM1; k=rsa; p= followed by the public key. v=DKIM1 must come first if it is present, k defaults to rsa, and an empty p= means the key has been revoked. If the text of a TXT record is stored as several strings, they are joined with no space before use.

An example for example.com with selector s1 (the key text is shortened):

Type: TXT
Host/Name: s1._domainkey
Value: v=DKIM1; k=rsa; p=MIIBIjANBgkq...IDAQAB

Check whether your DNS host adds the domain for you. If it does, typing the full name can create s1._domainkey.example.com.example.com.

Some providers give CNAME records instead of a TXT record, pointing at a key the provider hosts. Follow the record type your provider gives.

Create the DKIM record, step by step

At your DNS host, work in this order.

  1. Find who hosts your DNS: check the nameservers, because that is not necessarily your registrar. Our guide to finding your registrar and DNS host shows how.
  2. Open the DNS records for the domain.
  3. Add a record of the type your provider gives.
  4. Set the host to selector._domainkey, entered the way your DNS host expects it.
  5. Paste the value exactly as given, in one record.
  6. Leave the TTL as it is unless your sender says otherwise.
  7. Save, then go back to the sending service and switch signing on if it asks you to. In Google's DKIM setup guide, for example, authentication is started only after the record is published, and it can take up to 48 hours after the record is added for DKIM to start working.

Check that it works

First look up the TXT record at selector._domainkey.yourdomain with any DNS lookup tool. You should see the value your provider gave you. If the provider supplied a CNAME, look up that instead.

Then send a test message to an outside mailbox, not to yourself. Open the original message and look for dkim=pass in the Authentication-Results header. In the DKIM-Signature header, d= should show your domain and s= your selector. If the result is not a pass, the header tells you where to look:

  • No DKIM-Signature header at all. Signing is not switched on, or the message did not go through that service.
  • dkim=fail. The published key does not match the signing key, the value was altered when it was pasted, or something changed the message after signing, such as an outbound gateway adding a footer (Google's guide warns about this).
  • Record not found, or no key. The record is not visible yet, the selector is wrong, or the host name is wrong.

Key length and rotation

RFC 8301, which updates RFC 6376, says signers must use RSA keys of at least 1024 bits and should use at least 2048 bits. Receivers must handle keys from 1024 to 4096 bits and must not accept signatures made with keys under 1024 bits. Signing must use rsa-sha256; rsa-sha1 must not be used. Google's guide recommends 2048-bit keys where the domain host supports them, and 1024 otherwise.

To rotate a key, RFC 6376 describes this order:

  1. Publish the new key under a new selector beside the old one.
  2. Switch signing to the new key.
  3. Remove the old record.

Rotate on a schedule you set, and at once if the private key may have leaked or you stop using the service. To retire a key, publish its record with an empty p=, which marks it as revoked once receivers see the change in DNS.

Common mistakes

  • A long key entered as two separate records. A 2048-bit key may be too long for one text string at some DNS hosts (Google's guide notes that some hosts limit TXT record length). The fix is several quoted strings inside one TXT record, which receivers join with no space (RFC 6376): never two records, and no stray spaces or line breaks inside the key.
  • The wrong selector, or the domain typed twice in the host field. Check the exact selector and how your DNS host appends the domain.
  • Two records under the same selector. Keep exactly one record per selector.
  • The private key pasted instead of the public one. Only the public key belongs in DNS.
  • The record published but signing never switched on. The sending service has to start signing once the record is live.
  • A gateway or footer tool changing messages after signing. Anything that alters a message after it is signed, such as an added footer, can break the signature.
  • The testing flag left on. t=y means the domain is testing DKIM, and receivers must not treat its mail differently from unsigned mail.
  • Old selectors left for services you no longer use. Remove records you no longer need.

Two SPF records is a different problem, and an SPF one: a domain should publish one SPF policy, and adding DKIM records does not change it. The next section links to our guide that covers SPF.

How DKIM works with SPF and DMARC

SPF lists the servers allowed to send for the domain. DKIM signs the message. DMARC checks that SPF or DKIM passed for a domain matching the visible From address, and states what receivers should do with mail that fails. Google recommends setting up SPF and DMARC alongside DKIM, and says bulk senders, those sending 5,000 or more messages a day, must set up all three.

For the other records, see our guide to email DNS records. If your mail is landing in the wrong place, read why business email goes to spam.

A worked example

Example Joinery is a fictional business at example.com. It sends staff mail from its mail provider and invoices from an invoicing service. It takes a selector and key from each, mail2026 for the mail provider and inv1 for the invoicing service, publishes two records, one under each selector, switches signing on in both services and sends test messages. The tests show dkim=pass with d=example.com and each selector. That is a normal shape: one key and selector per sending service, all under the same domain.

Frequently asked questions

Can I create a DKIM record without my mail provider?

The record must match the private key that signs your mail, so it comes from whoever signs. If that is your own server, you make it there.

TXT or CNAME?

Use the record type your provider gives: some supply a TXT record to copy, others a CNAME that points to the provider's key.

How long does DKIM take to start working?

Until the record is visible in DNS and the sender has switched signing on; the step-by-step section gives one provider's figure.

Do I need DKIM if I already have SPF?

It is usually worth having both: they check different things, and Google recommends both alongside DMARC.

Can one domain have more than one DKIM record?

Yes: a domain can have several DKIM records, one per selector, which lets different sending services sign mail for it.

Where GridOnBoard fits

GridOnBoard's business email on your own domain is listed as arriving this week. When it opens, you connect a domain your business already owns, and the records it needs for email and your website are set up for you. It is part of one $26 a month subscription for the whole business.

Check what is available today.