To send authenticated emails through Mailgun, you must configure DKIM (DomainKeys Identified Mail) for your domain. DKIM allows Mailgun to digitally sign your outgoing emails so receiving mail servers can verify that the messages are legitimate and sent from an authorized source.
Setting up DKIM requires adding the DKIM TXT record provided by Mailgun to your domain’s DNS settings. Once verified, Mailgun will automatically sign all outgoing emails with this DKIM key.
Log in to your Mailgun dashboard.
Navigate to Sending → Domains.
Select the domain you want to configure.
Locate the DNS Records section.
Mailgun will display the DKIM TXT record you need to add to your DNS.
The record will look similar to this:
Host / Name
k1._domainkey.yourdomain.com
Type
TXT
Value
v=DKIM1; k=rsa; p=PUBLIC_KEY
The public key in this record will be used by receiving servers to verify the DKIM signature of your emails.
Log in to your DNS provider (for example Cloudflare, GoDaddy, Namecheap, etc.) and create a new TXT record using the details provided by Mailgun.
Typical configuration:
Host / Name
k1._domainkey
Type
TXT
Value
v=DKIM1; k=rsa; p=PUBLIC_KEY
Save the DNS record after adding it.
DNS changes may take several minutes to propagate but can take up to 24 hours depending on your DNS provider.
If you are using a subdomain for sending emails, make sure the DKIM hostname includes the subdomain.
Example:
If your sending domain is
mail.yourdomain.com
Mailgun may provide a DKIM record like:
k1._domainkey.mail.yourdomain.com
In most DNS panels, you would enter:
Host / Name
k1._domainkey.mail
This ensures the DKIM record is correctly applied to the subdomain.
After adding the DNS record:
Return to the Mailgun Domains page.
Wait for Mailgun to detect the DNS record.
Once detected, the domain will show as Verified or Active.
After verification, Mailgun will automatically sign all outgoing emails with DKIM.
For DMARC authentication to pass, the domain used in the DKIM signature must match the domain used in the From address of your emails.
When DKIM is configured correctly, Mailgun signs your emails with the appropriate domain, helping your messages pass authentication checks and improving deliverability.