Free Tool

Free DKIM Record Generator

Generate DKIM key pairs and DNS TXT records entirely in your browser. No data leaves your device — keys are created client-side using the Web Crypto API.

What Is DKIM?

DKIM (DomainKeys Identified Mail) is an email authentication protocol that lets the receiving mail server verify that an email was actually sent by the domain it claims to come from and that the message wasn't tampered with in transit. It works by attaching a cryptographic signature to every outgoing email, which the recipient can validate against a public key published in your domain's DNS records.

Think of DKIM as a tamper-evident seal on every email you send. When your mail server sends a message, it uses a private key to create a unique digital signature based on the email's content — the headers, the body, or both. That signature is embedded directly into the email as a DKIM-Signature header. When the receiving server gets the email, it looks up your public key in DNS and uses it to verify the signature. If the signature checks out, the server knows two things: the email genuinely came from your domain, and nobody altered it after it was signed.

DKIM is one of the three pillars of modern email authentication, alongside SPF (Sender Policy Framework) and DMARC (Domain-based Message Authentication, Reporting, and Conformance). While SPF verifies which servers are allowed to send email for your domain, DKIM verifies the integrity of the message itself. DMARC ties the two together with a policy layer that tells receiving servers what to do when authentication fails.

Unlike SPF, DKIM survives email forwarding. Because the signature is embedded in the email headers rather than being tied to the sending server's IP address, a forwarded email can still pass DKIM verification as long as the message content hasn't been modified. This makes DKIM especially important for organizations whose emails are frequently forwarded, such as mailing lists, newsletters, and automated notifications.

How DKIM Key Pairs Work

DKIM uses asymmetric cryptography — a pair of mathematically linked keys where one key signs data and only the other key can verify that signature. Here's how the two keys are used in practice:

Private Key

Lives on Your Mail Server

The private key stays on your mail server and is never shared with anyone. Your mail server uses it to create a unique cryptographic signature for every outgoing email. This signature is added to the email's DKIM-Signature header before the message leaves your server.

Public Key

Published in DNS

The public key is published as a DNS TXT record at selector._domainkey.yourdomain.com. Receiving mail servers query this record to retrieve your public key, then use it to verify the DKIM signature on incoming emails from your domain.

The Signing and Verification Flow

  1. 1
    Your mail server composes the email.

    The email is prepared with all its headers and body content, ready to be sent.

  2. 2
    The server creates a hash of the message content.

    Using the algorithm specified in your DKIM configuration (typically SHA-256), the server generates a hash of the email headers and body.

  3. 3
    The hash is signed with your private key.

    The server encrypts the hash using your RSA private key, producing a unique digital signature that is only valid for this specific email.

  4. 4
    The signature is added to the email headers.

    The signature, along with metadata like the selector name, signing algorithm, and which headers were signed, is inserted as a DKIM-Signature header.

  5. 5
    The receiving server looks up your public key.

    When the email arrives, the receiving server extracts the selector from the DKIM-Signature header and queries your DNS for the corresponding public key.

  6. 6
    The signature is verified.

    The receiving server uses your public key to decrypt the signature, then independently hashes the email content and compares the two values. If they match, DKIM passes.

The beauty of this system is that the private key never needs to leave your server. Even if someone intercepts the email and sees the signature, they cannot forge signatures for future emails without possessing the private key. And because the signature covers the email content, any modification to the message after signing will cause the verification to fail.

Choosing Your DKIM Selector

A DKIM selector is a short text string that identifies which DKIM key pair a particular email was signed with. It appears in two places: the DKIM-Signature header of every outgoing email, and the DNS hostname where the corresponding public key is published. The selector is what allows a domain to have multiple active DKIM keys at the same time.

When a receiving server processes an email with a DKIM signature, it reads the s= tag from the DKIM-Signature header to determine the selector. It then constructs the DNS query as selector._domainkey.domain.com and retrieves the public key. Without selectors, you could only have one DKIM key per domain — which would make key rotation and multi-provider setups impossible.

Naming Conventions

Selectors can be any alphanumeric string. There is no standard naming requirement, but using a descriptive, consistent naming scheme will save you headaches down the road. Here are common approaches:

Provider-based:google, sendgrid, mailgun, hubspot

Name the selector after the email service that uses it. Easy to audit.

Date-based:dkim202604, q2-2026, 2026apr

Include the date or quarter when the key was generated. Simplifies key rotation tracking.

Purpose-based:marketing, transactional, support

Name the selector after the type of email it signs. Useful when different teams manage different streams.

Default:default, dkim, mail, s1

Simple generic names. Fine for single-provider setups.

Multiple Selectors

Most organizations need more than one DKIM selector. If you send email through Google Workspace for internal communication, SendGrid for marketing campaigns, and a CRM for sales outreach, each service needs its own DKIM key pair with its own selector. This is perfectly normal and supported by the DKIM specification.

Multiple selectors also enable zero-downtime key rotation. You can publish a new key with a new selector, configure your mail server to start signing with it, and then remove the old selector once DNS propagation is complete. At no point do incoming emails fail DKIM verification.

1024-bit vs 2048-bit DKIM Keys

The key length determines the cryptographic strength of your DKIM signature. Longer keys are harder to break but produce larger DNS records. Here's the practical comparison:

1024-bit

  • ~175 characters in the DNS TXT record
  • Compatible with all DNS providers
  • Considered minimum acceptable security
  • Theoretically breakable with massive compute resources
  • Still widely used but being phased out

2048-bit Recommended

  • ~350 characters in the DNS TXT record
  • Compatible with most modern DNS providers
  • Recommended by RFC 6376 (DKIM specification)
  • Computationally infeasible to break with current technology
  • Required by some enterprise mail policies

When to Use 1024-bit

The only legitimate reason to use a 1024-bit key is if your DNS provider has a character limit on TXT records that prevents you from publishing a full 2048-bit public key. Some older DNS management interfaces cap TXT records at 255 characters per string, which can truncate a 2048-bit key. Most modern providers handle this by splitting the record into multiple strings automatically, but if yours doesn't, a 1024-bit key is a reasonable fallback.

Compatibility Notes

All major email providers — Gmail, Outlook, Yahoo, Apple Mail — support both 1024-bit and 2048-bit DKIM keys. On the DNS side, Cloudflare, Namecheap, GoDaddy, Route 53, and Google Cloud DNS all support 2048-bit keys without issues. If you are using any mainstream provider from the last decade, 2048-bit will work fine. When in doubt, generate a 2048-bit key with our tool above, try adding it to your DNS, and fall back to 1024-bit only if the record doesn't publish correctly.

How to Add Your DKIM Record to DNS

Once you've generated your DKIM key pair using the tool above, you need to publish the public key as a DNS TXT record so receiving mail servers can find it. Here are step-by-step instructions for the most common DNS providers:

Cloudflare

  1. 1. Log in to your Cloudflare dashboard and select the domain.
  2. 2. Navigate to DNS > Records and click Add Record.
  3. 3. Set Type to TXT.
  4. 4. In the Name field, enter selector._domainkey (replace “selector” with your actual selector).
  5. 5. Paste the full record value (starting with v=DKIM1; k=rsa; p=) into the Content field.
  6. 6. Set TTL to Auto or 3600 and click Save.

Namecheap

  1. 1. Log in to Namecheap and go to Domain List > Manage for your domain.
  2. 2. Click Advanced DNS.
  3. 3. Under Host Records, click Add New Record.
  4. 4. Select Type TXT Record.
  5. 5. Set Host to selector._domainkey.
  6. 6. Paste the record value and set TTL to Automatic or 1800. Click the checkmark to save.

GoDaddy

  1. 1. Log in to GoDaddy and navigate to My Products > DNS for your domain.
  2. 2. Click Add under the Records section.
  3. 3. Select Type TXT.
  4. 4. Set Name to selector._domainkey.
  5. 5. Paste the record value into the Value field.
  6. 6. Set TTL to 1 Hour and click Save.

AWS Route 53

  1. 1. Open the Route 53 console and navigate to your hosted zone.
  2. 2. Click Create Record.
  3. 3. Set Record Name to selector._domainkey.
  4. 4. Set Record Type to TXT.
  5. 5. In the Value field, wrap the entire record value in double quotes.
  6. 6. Set TTL to 3600 and click Create Records.

After adding the record, DNS propagation typically takes between 15 minutes and 4 hours. Full global propagation can take up to 48 hours in rare cases. You can verify your record is live by using our DKIM Checker or our DNS Checker.

Configuring Your Mail Server

After publishing your public key in DNS, you need to install the private key on your mail server so it can sign outgoing emails. The process varies depending on your mail server or email service provider.

Postfix with OpenDKIM

Postfix is the most common open-source mail server for Linux. DKIM signing is handled by OpenDKIM, which runs as a milter (mail filter).

  1. 1. Install OpenDKIM: sudo apt install opendkim opendkim-tools
  2. 2. Save the private key to /etc/opendkim/keys/yourdomain.com/selector.private
  3. 3. Configure /etc/opendkim.conf with your domain, selector, and key path.
  4. 4. Add the OpenDKIM milter to Postfix's main.cf configuration.
  5. 5. Restart both OpenDKIM and Postfix.

Google Workspace

Google Workspace generates its own DKIM keys through the Admin Console. You do not upload a custom private key.

  1. 1. Go to Google Admin Console > Apps > Google Workspace > Gmail > Authenticate email.
  2. 2. Select your domain and click Generate New Record.
  3. 3. Choose your DKIM key bit length (2048-bit recommended).
  4. 4. Copy the DNS record provided and add it to your DNS as a TXT record.
  5. 5. Return to the Admin Console and click Start Authentication.

Note: For Google Workspace, use the key Google provides rather than generating your own. Use our DKIM generator for custom mail servers or services that require you to supply your own key pair.

Microsoft 365

Microsoft 365 also manages DKIM signing internally but requires you to publish CNAME records that point to Microsoft's DKIM infrastructure.

  1. 1. Go to Microsoft 365 Defender > Policies & rules > Threat policies > Email authentication settings > DKIM.
  2. 2. Select your domain. Microsoft will show you two CNAME records to publish.
  3. 3. Add both CNAME records to your DNS (they point to selector1-yourdomain-com._domainkey.yourtenant.onmicrosoft.com).
  4. 4. Return to the Microsoft 365 Defender portal and enable DKIM signing.

Note: Like Google Workspace, Microsoft 365 handles its own key pair internally. Use our generator when configuring custom mail infrastructure.

Testing Your DKIM Setup

After publishing your DKIM record in DNS and configuring your mail server with the private key, you should verify that everything is working correctly before relying on it for production email.

1
Verify your DNS record is published.

Use our DKIM Checker to query your selector._domainkey record and confirm it returns the correct public key. If it returns nothing, DNS hasn't propagated yet or the record was entered incorrectly.

2
Send a test email.

Send an email from the mail server you configured with the private key. Send it to a Gmail, Outlook, or Yahoo address you control.

3
Check the email headers.

Open the received email and view the full headers (in Gmail: three dots > Show Original). Look for the Authentication-Results header. You should see dkim=pass.

4
Verify DKIM alignment.

The d= value in the DKIM-Signature header should match the domain in your From address. If it doesn't, DKIM will pass but won't satisfy DMARC alignment.

5
Test with our Email Header Analyzer.

Copy the full email headers and paste them into our Email Header Analyzer for a detailed breakdown of all authentication results.

Verify your new DKIM record with our free DKIM Checker. It will confirm that your public key is published correctly and accessible to receiving mail servers.

Frequently Asked Questions

What is a DKIM record?

A DKIM record is a DNS TXT record that contains the public key for your domain's DKIM authentication. It is published at selector._domainkey.yourdomain.com and allows receiving mail servers to verify the DKIM signatures on your outgoing emails. The record typically looks like v=DKIM1; k=rsa; p= followed by the Base64-encoded public key.

How do I generate a DKIM key?

Use the DKIM generator at the top of this page. Enter your domain name, choose a selector name, select your preferred key length (1024 or 2048-bit), and click Generate. You will receive a private key for your mail server and a public key formatted as a DNS TXT record. Everything is generated in your browser -- no data is sent to any server.

What is a DKIM selector?

A DKIM selector is a name that identifies a specific DKIM key pair for your domain. It allows you to have multiple DKIM keys active at the same time -- one for each email service you use. The selector is included in the DKIM-Signature header of every signed email and determines which DNS record the receiving server queries for the public key.

Should I use 1024 or 2048-bit DKIM keys?

Use 2048-bit keys as your default choice. They provide stronger security and are recommended by the DKIM specification (RFC 6376). Only fall back to 1024-bit if your DNS provider has character length limitations that prevent you from publishing the full 2048-bit public key.

Where do I add my DKIM record?

Add your DKIM record to your domain's DNS zone through your domain registrar or DNS hosting provider (Cloudflare, Namecheap, GoDaddy, Route 53, etc.). Create a new TXT record with the hostname selector._domainkey and paste the public key value from the generator as the record content.

How do I verify my DKIM record is working?

Use our free DKIM Checker to confirm the TXT record is published and returning the correct public key. Then send a test email and check the email headers for dkim=pass in the Authentication-Results header. If both checks succeed, your DKIM is working correctly.

Do I need DKIM for email?

DKIM is not technically required to send email, but it is effectively required for reliable email delivery. Gmail, Outlook, Yahoo, and other major providers all check for DKIM authentication. Without it, your emails are far more likely to be flagged as spam or rejected outright. Google and Yahoo now require DKIM for bulk senders.

What happens if DKIM fails?

When DKIM verification fails, the outcome depends on your DMARC policy. If your DMARC policy is p=none, the email may still be delivered but is more likely to land in spam. If your policy is p=quarantine, the email goes to spam. If your policy is p=reject, the email is bounced entirely. Check your DMARC configuration with our free DMARC Checker.

Next Steps

Your DKIM key pair is generated. Now make sure the rest of your email authentication stack is locked down:

Stop Wrestling With Email Authentication

ScaledMail configures SPF, DKIM, and DMARC correctly for every inbox from day one. No DNS headaches, no key management, no authentication gaps.

See ScaledMail Pricing