How to Set Up Mailgun With Cloudflare DNS for Sparkforge

By Sparkforge Support Team ·Last reviewed May 3, 2026

To use Mailgun with Sparkforge, sign up at Mailgun, add a domain or subdomain (US region), then add the five required DNS records — SPF, DKIM, two MX, and one CNAME — in Cloudflare and verify.

1. Sign up for Mailgun

  1. Create an account at mailgun.com.
  2. Verify the email address from your inbox.
  3. In Mailgun, go to Sending > Add New Domain.

2. Choose main domain or subdomain

Decide whether to add the root domain (e.g., companyname.com) or a subdomain (e.g., mg.companyname.com).

  • Main domain — only if it isn't used with Google Workspace or another mail provider.
  • Subdomain — recommended. Use anything like mg.companyname.com, replies.companyname.com, or support.companyname.com.

Set the region to US, not EU. Click Add Domain. Mailgun shows the DNS records you need — leave that screen open.

3. Add the five DNS records in Cloudflare

Log in to Cloudflare, select the account and domain, then go to DNS > Records.

First TXT record (SPF)

  1. Click + Add Record.
  2. Type: TXT.
  3. Name: the subdomain only — for mg.companyname.com use mg; for the root, use @.
  4. Content: v=spf1 include:mailgun.org ~all
  5. Click Save.

Second TXT record (DKIM)

  1. Click + Add Record.
  2. Type: TXT.
  3. Name: copy the host portion from Mailgun — everything before the root domain. For example, mx._domainkey.helpdesk on a subdomain or mailo._domainkey on the root.
  4. Content: paste the long DKIM value from Mailgun's second TXT record.
  5. Click Save.

First MX record

If you use Google Workspace on the root domain, set up Mailgun on a subdomain to avoid conflicts.

  1. Click + Add Record.
  2. Type: MX.
  3. Name: the subdomain (mg, replies) or @ for the root.
  4. Mail Server: mxa.mailgun.org
  5. Priority: 10.
  6. Click Save.

Second MX record

  1. Click + Add Record.
  2. Type: MX.
  3. Name: same as the first MX.
  4. Mail Server: mxb.mailgun.org
  5. Priority: 10.
  6. Click Save.

CNAME record

  1. Click + Add Record.
  2. Type: CNAME.
  3. Name: from Mailgun, copy the host before the root — e.g., email.mg for a subdomain or email for the root.
  4. Target: mailgun.org
  5. Click the orange cloud to switch from Proxied to DNS Only.
  6. Click Save.

4. Verify and connect to Sparkforge

  1. Return to Mailgun and click Verify DNS Settings. If anything is missing the green check, wait a few minutes and verify again.
  2. Once all records pass, copy the Mailgun API key from your Mailgun dashboard.
  3. Paste the API key into Sparkforge's Mailgun integration.
  4. Send a test email from a Sparkforge conversation to confirm delivery.

Frequently Asked Questions

Should I use the root domain or a subdomain for Mailgun?
A subdomain is recommended. The root domain only works if you're not using Google Workspace or another mail provider on it.
Why do I need to set the region to US?
Sparkforge's Mailgun integration assumes the US region. EU-region accounts won't connect properly.
Should the CNAME be proxied through Cloudflare?
No. Set it to DNS Only by clicking the orange cloud icon — proxying breaks Mailgun's tracking.
What if DNS records still aren't verifying after several minutes?
Confirm the host names don't include the root domain, the SPF and DKIM values match Mailgun's screen exactly, and the MX priority is 10. Re-click Verify DNS Settings.

Was this article helpful?