How to Set Up DKIM for Mailgun

Publish a DKIM TXT record provided by Mailgun to enable cryptographic email signing for your sending domain.

Quick Answer — The Record You Need

Record Type

TXT

Host / Name

smtp._domainkey

Value
v=DKIM1; k=rsa; p=YOUR_PUBLIC_KEY_FROM_MAILGUN

Mailgun generates a unique DKIM key for each domain. The default selector is smtp or a domain-specific selector.

Step-by-Step Setup

1

Log in to Mailgun

Go to app.mailgun.com and sign in.

2

Select your domain

Go to Sending > Domains and select your verified domain.

3

Copy the DKIM record

Mailgun displays the DKIM TXT record with the selector and public key. Copy both the host name and value.

4

Add the TXT record to DNS

Create a TXT record in your DNS provider with the host and value from Mailgun.

smtp._domainkey.yourdomain.com  TXT  "v=DKIM1; k=rsa; p=MIGfMA0GCSq..."
5

Verify in Mailgun

Click "Verify DNS Settings" in Mailgun. It will check the DKIM record.

Common Gotchas

  • Mailgun uses a TXT record for DKIM, not a CNAME. Copy the exact value from your Mailgun dashboard.
  • The DKIM selector varies. Older Mailgun accounts may use smtp._domainkey, while newer accounts may use a domain-specific selector. Always use the selector shown in your dashboard.
  • If using a subdomain (e.g., mg.yourdomain.com), the DKIM record goes under that subdomain: smtp._domainkey.mg.yourdomain.com.

Verify Your Setup

After adding your DNS records, use our free DKIM checker to verify everything is configured correctly. DNS changes typically propagate within minutes, but can take up to 48 hours.

Frequently Asked Questions

What DKIM selector does Mailgun use?

Mailgun typically uses smtp as the DKIM selector, but newer accounts may use different selectors. Check your Mailgun domain settings for the exact selector.

Is the Mailgun DKIM record a TXT or CNAME?

Mailgun uses a TXT record for DKIM containing the public key directly, unlike some providers that use CNAME records.

Can I rotate DKIM keys in Mailgun?

Yes. You can regenerate DKIM keys in the Mailgun dashboard. After regenerating, update the DNS TXT record with the new public key.

Related Guides