To set up DKIM: 1) Generate DKIM keys in your ESP's dashboard (they'll provide the public key), 2) Add the public key as a TXT or CNAME record in your DNS at selector._domainkey.yourdomain.com, 3) Enable DKIM signing in the ESP, 4) Verify by sending a test email and checking headers for dkim=pass. Most ESPs provide copy-paste DNS records—the setup is mostly DNS configuration.
How to Set Up DKIM for Any ESP: Complete Guide
DKIM Setup Overview
DKIM (DomainKeys Identified Mail) cryptographically signs your emails, proving they weren't modified in transit and came from an authorized sender. DKIM is one of the three pillars of email authentication, alongside SPF and DMARC.
The setup process:
- ESP generates a key pair (public + private)
- You add the public key to your DNS
- ESP signs outbound mail with the private key
- Receivers verify signatures using your public key
Step 1: Generate DKIM Keys
In Your ESP Dashboard
Every ESP has a domain authentication section. Common locations:
| ESP | Location |
|---|---|
| SendGrid | Settings → Sender Authentication → Authenticate Your Domain |
| Mailgun | Sending → Domains → DNS Records |
| Postmark | Sender Signatures → Add Domain |
| Mailchimp | Settings → Domain Verification |
| Klaviyo | Settings → Domains → Add Domain |
| HubSpot | Settings → Domain & URLs → Connect a domain |
The ESP generates:
- Private key: Kept by the ESP, used for signing
- Public key: Given to you for DNS
- Selector: A name to identify this key (e.g.,
s1,k1,google)
Generated Output Example
Your ESP provides something like:
DNS Record Type: TXT (or CNAME)
Host: s1._domainkey.yourdomain.com
Value: v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQ...
Or for CNAME:
Host: s1._domainkey.yourdomain.com
Target: s1.domainkey.sendgrid.net
Step 2: Add DNS Records
Log into your DNS provider and add the record exactly as provided.
For TXT Records
| Field | Value |
|---|---|
| Host/Name | s1._domainkey (or full FQDN depending on provider) |
| Type | TXT |
| Value | The DKIM key string from your ESP |
| TTL | 3600 (or default) |
For CNAME Records
| Field | Value |
|---|---|
| Host/Name | s1._domainkey |
| Type | CNAME |
| Target | The target domain from your ESP |
| TTL | 3600 |
Practitioner note: CNAME records are easier to maintain—when the ESP rotates keys, they update their end and your DNS automatically follows. TXT records require manual updates during key rotation. Choose CNAME when offered.
DNS Provider Examples
Cloudflare:
- DNS → Add record
- Type: CNAME (or TXT)
- Name:
s1._domainkey - Target/Content: [ESP-provided value]
GoDaddy:
- DNS Management → Add
- Type: CNAME or TXT
- Host:
s1._domainkey - Points to / Value: [ESP-provided value]
Step 3: Enable DKIM Signing
Some ESPs start signing automatically once DNS is verified. Others require manual activation.
Check your ESP dashboard:
- SendGrid: Click "Verify" after adding DNS
- Mailgun: Domain status shows "Active" when verified
- Postmark: Click "Verify DNS" then "Verify DKIM"
- Google Workspace: Admin Console → Apps → Gmail → Authenticate email → Start Authentication
Step 4: Verify DKIM Works
Method 1: Send Test Email
- Send email from your ESP to a Gmail account
- Open the email in Gmail
- Click three dots → "Show original"
- Look for Authentication-Results:
dkim=pass [email protected] header.s=s1 header.b=abc123
dkim=pass confirms DKIM is working.
Method 2: MXToolbox DKIM Lookup
- Go to MXToolbox DKIM Lookup
- Enter your domain and selector (e.g.,
yourdomain.comands1) - Check that the key is found and valid
Method 3: dig Command
dig TXT s1._domainkey.yourdomain.com +short
Should return your DKIM public key.
ESP-Specific Setup Guides
SendGrid
- Settings → Sender Authentication → Domain Authentication
- Enter your domain, choose DNS host
- Add the provided CNAME records (usually 3 records for DKIM + SPF)
- Click "Verify"
Mailgun
- Sending → Domains → Add New Domain
- Add provided TXT records for DKIM
- Wait for verification (automatic)
Postmark
- Sender Signatures → Add Domain
- Copy the DKIM TXT record
- Add to DNS
- Click "Verify DKIM"
Google Workspace
- Admin Console → Apps → Google Workspace → Gmail
- Authenticate email → Generate new record
- Choose key length (2048-bit recommended)
- Add TXT record to DNS
- Start authentication
Microsoft 365
- Microsoft 365 Defender → Email & collaboration → Policies
- DKIM → Select domain → Enable
- Add provided CNAME records
- Wait for propagation and enable
Common Setup Issues
"DKIM record not found"
- Check the selector is correct (case-sensitive in some DNS providers)
- Wait for DNS propagation (15-60 minutes)
- Verify record is at
selector._domainkey.domain.com, notselector._domainkey
"DKIM signature verification failed"
- Key mismatch: Regenerate keys in ESP and update DNS
- Record too long: Some DNS providers truncate long TXT records. Use CNAME if available
- Wrong record type: Make sure you're using TXT if ESP specifies TXT
"Key too long for DNS"
DKIM 2048-bit keys exceed some DNS providers' single-string limit. Solutions:
- Use CNAME instead of TXT
- Split the key into multiple strings (some ESPs do this automatically)
- Contact DNS provider about TXT record limits
Practitioner note: The "record not found" error after setup is almost always propagation timing or a typo in the selector name. Wait an hour before troubleshooting further.
Multiple ESP Setup
You can have DKIM for multiple ESPs simultaneously—each uses different selectors:
google._domainkey.yourdomain.com → Google Workspace
s1._domainkey.yourdomain.com → SendGrid
smtp._domainkey.yourdomain.com → Mailgun
All can coexist. Receiving servers use the selector specified in the email's DKIM-Signature header to look up the correct key.
If you need help setting up DKIM for a complex multi-ESP configuration, schedule a consultation.
Sources
- RFC 6376: DomainKeys Identified Mail (DKIM) Signatures
- SendGrid: Domain Authentication
- Google Workspace: Turn on DKIM
- Microsoft: Use DKIM for email
v1.0 · March 2026
Frequently Asked Questions
How do I get DKIM keys from my ESP?
In your ESP's dashboard, look for 'Domain Authentication', 'Sender Authentication', or 'Email Authentication'. The ESP generates a key pair and gives you the public key to add to DNS.
Where do I add the DKIM DNS record?
Add a TXT (or CNAME) record at selector._domainkey.yourdomain.com. The selector is provided by your ESP (e.g., s1, google, k1). The value is the public key or CNAME target.
How do I verify DKIM is working?
Send a test email to Gmail, open it, click three dots → Show original, and look for 'dkim=pass' in Authentication-Results. Or use MXToolbox DKIM Lookup with your selector.
Do I need DKIM if I already have SPF?
Yes. SPF and DKIM serve different purposes. DKIM survives email forwarding (SPF doesn't), and DMARC alignment can use either. Both should be configured.
Can I use DKIM for multiple ESPs?
Yes. Each ESP uses different selectors, so multiple DKIM records can coexist. You might have google._domainkey for Workspace and s1._domainkey for SendGrid.
Want this handled for you?
Free 30-minute strategy call. Walk away with a plan either way.