Skip to content
English
  • There are no suggestions because the search field is empty.

Mailgun - SPF & DKIM Configuration

Mailgun is a cloud-based email delivery service that provides APIs for sending, receiving, tracking, and validating emails at scale, making it easy for developers to integrate reliable email functionality into their applications.

 

✅ SPF: Supported

✅ DKIM: Supported



Step 1: Log in to your Mailgun portal.
Step 2: In the left sidebar, expand the "Sending" section and select "Domains."



Step 3: Add a subdomain to your account. When doing so, select a 2048-bit DKIM key length, as this is the recommended option.

Important: Always use a subdomain, never your root domain. This prevents Mailgun's MX records from conflicting with your root domain's existing MX records.





Mailgun – SPF Record Configuration

Copy the SPF record provided by Mailgun and publish it in your DNS under the subdomain you added.


The example below shows how it should appear in Cloudflare.

Mailgun – DKIM Record Configuration

Copy the DKIM record from Mailgun and publish it in your DNS zone. The screenshot below shows an example of how this looks in Cloudflare.



Additional DNS Records

Along with SPF and DKIM, you'll also need to publish the following records:

  • MX records - required for email routing
  • Tracking CNAME record - required for click and open tracking




Tracking record:


In the DNS (Cloudflare):

DMARC Reporting (New Feature)

Mailgun now supports DMARC reporting. To enable it, add Mailgun's RUA and RUF email addresses to your existing DMARC record, if you already have one for that subdomain. Do not create a second DMARC record, each domain should have only one. Simply update the existing record with Mailgun's addresses.




Once all DNS records have been published and propagated, Mailgun will display a "Verified" status next to each record, confirming everything is active. You can also click on the “Check Status” button to see the up-to-date status of the records.



Your Mailgun SPF and DKIM setup is now complete, and you're ready to send DMARC-compliant emails. Make sure your DMARC record has both aspf and adkim set to relaxed (rather than strict) for best compatibility.