DKIM Setup Guide: Step-by-Step Configuration
Complete guide to setting up DKIM for your domain. Step-by-step instructions for generating keys, configuring your mail server, and publishing DNS records.
Last updated: 2026-02-06
Setting up DKIM involves three steps: generate a key pair, configure your mail server to sign emails, and publish the public key in DNS. This guide walks through each step.
DKIM Creator generates keys in your browser. No server-side processing, no accounts required.
Before You Start
You'll need:
- DNS access for your domain (GoDaddy, Cloudflare, Namecheap, etc.)
- Mail server access or admin access to your email provider
- A selector name — a label for your key (e.g.,
default,mail,2026q1)
Step 1: Generate Your DKIM Keys
Choose a selector
Your selector identifies which key to use. Common patterns:
defaultormailfor general use2026q1for date-based rotationgoogleorsendgridfor service-specific keys
Choose your key size
- 2048-bit (recommended) — Current security standard
- 1024-bit — Only if your DNS provider has TXT record length limits
Generate the key pair
Use DKIM Creator to generate your keys. You'll receive:
- A private key (PEM format) for your mail server
- A public key DNS record for your domain's DNS
Generate your DKIM keys
Create a key pair in your browser. Keys never leave your machine.
Step 2: Add the DNS Record
Add your public key as a TXT record in your domain's DNS:
| Field | Value |
|---|---|
| **Host/Name** | `selector._domainkey` (e.g., `mail._domainkey`) |
| **Type** | TXT |
| **Value** | The DNS record from DKIM Creator (starts with `v=DKIM1;`) |
| **TTL** | 3600 (1 hour) |
DNS Provider Examples
Cloudflare:
- Go to DNS → Records → Add Record
- Type: TXT, Name:
selector._domainkey, Content: your record
GoDaddy:
- Go to DNS Management → Add Record
- Type: TXT, Host:
selector._domainkey, Value: your record
Namecheap:
- Go to Advanced DNS → Add New Record
- Type: TXT, Host:
selector._domainkey, Value: your record
DNS changes can take up to 48 hours to propagate, though most complete within 1-2 hours. Wait for propagation before testing.
Step 3: Configure Your Mail Server
How you install the private key depends on your email setup:
Google Workspace
- Go to Admin Console → Apps → Google Workspace → Gmail
- Click "Authenticate email" under your domain
- Google generates keys automatically — use their process
Microsoft 365
- Go to Microsoft Defender → Policies → Email authentication → DKIM
- Select your domain
- Enable DKIM signing (Microsoft provides keys)
Self-Hosted (Postfix + OpenDKIM)
# Install OpenDKIM
sudo apt install opendkim opendkim-tools
# Copy your private key
sudo cp mail.private /etc/opendkim/keys/yourdomain.com/
sudo chmod 600 /etc/opendkim/keys/yourdomain.com/mail.private
# Configure and restart
sudo systemctl restart opendkim
sudo systemctl restart postfix
Transactional Email Services
Most services (SendGrid, Mailgun, SES) have their own DKIM setup process in their dashboard. They typically provide DNS records for you to add.
Step 4: Verify Your Setup
After DNS propagation, verify everything is working:
Check DNS Record
dig TXT selector._domainkey.yourdomain.com +short
You should see your public key record.
Send a Test Email
Send an email to a Gmail account and check the headers:
- Open the email in Gmail
- Click the three dots → "Show original"
- Look for
dkim=passin the Authentication-Results header
Authentication-Results: mx.google.com;
dkim=pass header.d=yourdomain.com header.s=selector
Common Setup Mistakes
Wrong selector in DNS
The DNS hostname must match your selector exactly. If your selector is mail, the record goes at mail._domainkey.yourdomain.com.
Private key permissions
The private key file must be readable only by the mail server process. Use chmod 600 on Linux.
Forgetting the ._domainkey suffix
The hostname is selector._domainkey, not just the selector name.
Testing before DNS propagation Wait at least 1-2 hours after adding the DNS record before testing.
Key mismatch Make sure the private key on your server and the public key in DNS are from the same key pair.
After Setup
Once DKIM is working:
- Set up SPF — Authorize your sending servers
- Set up DMARC — Add a policy that uses DKIM results
- Monitor — Check DMARC reports for authentication failures
- Plan rotation — Schedule regular key rotation (annually is common)
Related Articles
Ready to set up DKIM? Start by generating your keys.