How to Set Up Mailgun With Cloudflare DNS for Sparkforge
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
- Create an account at mailgun.com.
- Verify the email address from your inbox.
- 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, orsupport.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)
- Click + Add Record.
- Type: TXT.
- Name: the subdomain only — for
mg.companyname.comusemg; for the root, use@. - Content:
v=spf1 include:mailgun.org ~all - Click Save.
Second TXT record (DKIM)
- Click + Add Record.
- Type: TXT.
- Name: copy the host portion from Mailgun — everything before the root domain. For example,
mx._domainkey.helpdeskon a subdomain ormailo._domainkeyon the root. - Content: paste the long DKIM value from Mailgun's second TXT record.
- Click Save.
First MX record
If you use Google Workspace on the root domain, set up Mailgun on a subdomain to avoid conflicts.
- Click + Add Record.
- Type: MX.
- Name: the subdomain (
mg,replies) or@for the root. - Mail Server:
mxa.mailgun.org - Priority: 10.
- Click Save.
Second MX record
- Click + Add Record.
- Type: MX.
- Name: same as the first MX.
- Mail Server:
mxb.mailgun.org - Priority: 10.
- Click Save.
CNAME record
- Click + Add Record.
- Type: CNAME.
- Name: from Mailgun, copy the host before the root — e.g.,
email.mgfor a subdomain oremailfor the root. - Target:
mailgun.org - Click the orange cloud to switch from Proxied to DNS Only.
- Click Save.
4. Verify and connect to Sparkforge
- Return to Mailgun and click Verify DNS Settings. If anything is missing the green check, wait a few minutes and verify again.
- Once all records pass, copy the Mailgun API key from your Mailgun dashboard.
- Paste the API key into Sparkforge's Mailgun integration.
- 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?
Thanks for the feedback.