Skip to content
DMARC Pulse

Learn

How to set up DKIM: key, DNS record and first test

How to set up DKIM: create a key and selector, publish the DNS record, turn on signing after it resolves, then confirm dkim=pass in a test message.

Before you start

Here is how to set up DKIM: create a key pair under a selector, publish the public key in your domain's DNS, then turn on signing where your mail is sent from. DKIM (DomainKeys Identified Mail) adds a digital signature to each message, and receivers check it against the public key in DNS. A selector is a label that names one key, so a domain can keep several. Each key lives at selector._domainkey.yourdomain.

You need access to the domain's DNS and admin access to every service that sends mail with your domain in the From address.

What you publish depends on who signs the mail:

Mail sent from Who creates the key What you publish
Google Workspace The Admin console One TXT record, by default at google._domainkey
Microsoft 365 Microsoft Two CNAME records, selector1._domainkey and selector2._domainkey
Amazon SES with Easy DKIM Amazon SES Three CNAME records shown in the console
Your own mail server You One TXT record for the selector you choose

A CNAME points the name at a host the service runs, where the key is published.

Steps

  1. Set the key length and the selector. Choose 2048 bits if your DNS host can store it. On your own server, pick a simple selector, such as mail1. Use a new selector for each new key, so you never overwrite a key that signed mail still in transit.

  2. Create the key or copy the records. In Google Workspace, go to Apps, Google Workspace, Gmail, then Authenticate email, and generate a new record. In Microsoft 365, open the DKIM tab under Email authentication settings in the Defender portal and try to enable your domain. The error dialog is expected. The domain's details then list the values under Publish CNAMEs. In Amazon SES, create the domain identity, then copy the records from Publish DNS records. On your own server, create the pair with the DKIM generator and keep the private key on the system that signs. See also DKIM on Google Workspace and DKIM on Microsoft 365.

  3. Publish the record at your DNS host. For a TXT key, the name is your selector followed by ._domainkey, and the value follows this format:

    TXT
    v=DKIM1; k=rsa; p=YOUR_PUBLIC_KEY

    For CNAME records, copy the target as shown, and the name minus the domain if your panel adds it (see below).

  4. Wait until the record is visible. Google says DKIM can take up to 48 hours after you add the key, and Amazon SES allows up to 72 hours for DNS changes. Run the lookup under Confirm it worked before you continue.

  5. Turn on signing only after that. If a message is signed and the receiver finds no key, the signature fails permanently. With p=quarantine or p=reject in your DMARC record, that mail can be quarantined or rejected unless SPF passes and aligns. In Google Workspace, click Start authentication. In Microsoft 365, select Sign messages for this domain with DKIM signatures, which takes effect only once Microsoft detects the CNAME records. Amazon SES finishes on its own when it detects the records. On your own server, give the signing software the private key, the domain and the selector.

  6. Repeat for each service and domain. Give each service its own selector. Google requires a unique key for each domain.

How to add a DKIM record to your DNS

Keep the underscore in the name. Some DNS panels add your domain on their own. There, leave it out, including from CNAME names shown in full: enter only the part before it, such as mail1._domainkey or selector1._domainkey.

After p=, paste the public key without the BEGIN and END lines or line breaks. A 2048-bit key does not fit in one 255-character string. If your panel won't accept the full value as one string, Google tells you to split it into several quoted strings in the same record, and RFC 6376 has receivers join them with no spaces.

Confirm it worked

  1. Look up the record with your own selector and domain. For a CNAME setup, use -type=CNAME.

    nslookup -type=TXT google._domainkey.example.com 1.1.1.1

    The DKIM checker also reads the key and its length.

  2. Send a test message to someone on Gmail or Google Workspace. Google says a message to yourself does not verify DKIM.

  3. In the recipient's mailbox, open the full headers. In Gmail, next to Reply, click More, then Show original. Paste them into the email header analyzer.

  4. Find Authentication-Results and look for dkim=pass. The format varies by receiver, and some show DKIM=OK.

  5. Check the signing domain in header.d=. If the receiver shows only header.i=, read the d= tag in the DKIM-Signature header instead. For DMARC, the d= domain must align with your From domain: the same organizational domain by default, or an exact match with adkim=s.

Common mistakes

  • A TXT record where the service expects a CNAME. Microsoft 365 supports only CNAME records for DKIM. A TXT record at selector1._domainkey leaves the status at CnameMissing.
  • A pass under the service's domain. Microsoft notes that many hosted services sign with the service domain and add your domain only after you configure DKIM. Only the signature aligned with your From domain counts for DMARC.
  • Deleting an old key too soon. RFC 6376 describes keeping both public keys published during a transition, while mail signed with the old key may still be in transit. Deleting it early causes DKIM failures.

Check it now

Create a DKIM key pair and TXT record

Open the DKIM Generator

Frequently asked questions

How long does DKIM take to start working?
It depends on the service and on DNS. Google says DKIM can take up to 48 hours to start working after you add the key. Amazon SES says DNS changes can take up to 72 hours to propagate. Microsoft says it takes a few minutes or possibly longer to detect new CNAME records.
Should I use a 1024-bit or a 2048-bit DKIM key?
Use 2048 bits if your DNS host can store the longer record. RFC 8301 says signers must use at least 1024 bits and should use at least 2048. Gmail requires 1024 bits or longer for mail to personal Gmail accounts and recommends 2048. Use 1024 only if your DNS host cannot publish the longer key.
How do I configure DKIM on my own mail server?
Generate a key pair, publish the public key in a TXT record at your selector, and give your signing software the private key, the domain and the selector. Keep the private key on the system that signs. The exact settings depend on the software, so follow its documentation.

Sources consulted

RFC 6376 §3.1: Selectors
checked 2026-11-08
RFC 8301 §3.2: Key Sizes
checked 2026-11-08
RFC 8601 §2.7.1: DKIM
checked 2026-11-08
Amazon SES: Easy DKIM
checked 2026-11-08

Related pages

Keep it healthy

Know the moment something breaks

Point your DMARC reports to DMARC Pulse and see who sends email as your domain, what fails and why — with a calm alert when anything changes.

Free plan: 1 domain, no credit card.