MailGun DKIM and SPF Setup: Step by Step | EasyDMARC

MailGun DKIM and SPF Setup: Step by Step

2 Min Read

Mailgun is one of the leading email delivery services for businesses worldwide. It’s an API-based email delivery service for sending, receiving, and tracking emails. The app was founded in 2010. For the last decade, it has provided powerful APIs that enable you to send, receive and track email effortlessly whether you use Python, Ruby, PHP, C#, Node.js, or Java. This authentication guide will cover the Mailgun DKIM and SPF setup.

Setting up DKIM

Step 1: Head to your Mailgun portal.

Step 2: On the left of the screen, click on the collapsible “Sending” tab and choose “Domains.”

Step 3: From there, add a subdomain.

N.B: Subdomain is important, so the MX provided by Mailgun doesn’t interfere with your root domain’s MX records.

Add domain from

Step 4: Mailgun will provide you with a couple of records that you’ll need to add to your DNS zone.

Provided Mailgun records to be added to the DNS

Step 5: Copy all the records and add them to your DNS zone.

Step 6: Wait a couple of minutes and click “Verify DNS settings.”

Adding SPF to Mailgun

Adding DKIM to Mailgun

Adding MX to Mailgun

Adding CNAME for tracking

Note: Turn off the proxy status if you’re using Cloudflare.

Step 8: Mailgun will validate the records for the added subdomain with a green checkmark.

Mailgun Verified badge for the subdomain

Now, your Mailgun DKIM and SPF setup is complete. Now you can send DMARC compliant emails with Mailgun. (Make sure you have your aspf and adkim set to “relaxed” instead of “strict” in your DMARC record.) More about DMARC tags here.

DMARK and SPF setup pass and aligned

Note: Wait at least 24 hours to receive the updated reports.

If you have any further questions, don’t hesitate to contact the EasyDMARC support team via the form on our website or at [email protected].

Content Team Lead | EasyDMARC
Hasmik talks about DMARC, email security, and cyberawareness. She finds joy in turning tough technical concepts into approachable and fun articles in plain language.


Inline Feedbacks
View all comments

succees We’re glad you joined EasyDMARC newsletter! Get ready for valuable email security knowledge every week.

succees You’re already subscribed to EasyDMARC newsletter. Continue learning more about email security with us