Connect Mailgun to SiteOps
Few email APIs have been around as long as Mailgun — developers have trusted it for well over a decade to get mail out reliably. The deal is simple: verify a domain once by pasting a few DNS records, and from then on anything holding the right key can send email from that domain through Mailgun's infrastructure.
SiteOps is one of those things holding a key. It writes and schedules the emails; Mailgun owns the delivery — so what you approve goes out from a domain readers recognise, and the sent, opened and clicked counts come back to sit next to your other channels.
The setup has two halves: verify a sending domain in Mailgun (the DNS part — this guide includes an agent prompt for it), then give SiteOps the sending key and a from address. Until both halves exist, scheduled emails wait safely as drafts — nothing is ever sent half-configured. One trap to know up front: Mailgun starts every account with a sandbox domain that can only email a handful of pre-approved addresses. It is for testing, and it is not what you connect.
Set it up, step by step
0 of 9 done
- Send
- Domains
- Add new domain
- Settings
- API keys
The sending key's journey — from Mailgun's settings to one SiteOps field - Settings
- Mailgun
- Save
Let an agent do it
An agent with access to your DNS can add Mailgun's SPF, DKIM and tracking records for you.
Add the Mailgun domain verification records to my DNS.
1. I added <my sending domain, e.g. mg.example.com> in Mailgun and its domain page lists the DNS records to add — SPF and DKIM as TXT records, plus a tracking CNAME. Here they are exactly as displayed: <each record: type, host, value>.
2. Open the DNS zone for the domain at <my DNS host, e.g. Cloudflare or the registrar> and add each record with the exact type, host and value. Watch for the host trap: if the DNS host auto-appends the domain, enter only the prefix (for example mailo._domainkey.mg, not the full host), so it does not end up doubled.
3. Check each record resolves: dig TXT <host> +short for SPF and DKIM, dig CNAME <host> +short for the tracking record.
4. Tell me when they resolve so I can press Verify in Mailgun.Creating the Mailgun account, pressing Verify, copying the API key and pasting it into SiteOps stay with you.
If something does not work
- The domain is stuck on Unverified
- Almost always a copying issue. Open your DNS and compare each record against what Mailgun shows — type, host and value must match exactly, and some registrars append your domain to the host on their own, doubling it. Fixed records can still take a few hours to propagate; press Verify again after a break.
- My test emails only arrive at my own address
- You are sending from the sandbox domain, which only delivers to recipients you manually authorised. Add and verify a real domain (the steps above) and set the from address on it — the sandbox is for kicking the tires, not for readers.
- The key saved but my emails still sit as drafts
- The from address is the missing half. Open the Email section in SiteOps settings and set the sender name and address — the address has to be on the domain you verified in Mailgun. The draft's note says exactly which half the gate is waiting on.
- My first emails landed in spam
- New sending domains start with no reputation. Keep SPF and DKIM verified, send steadily rather than in bursts, write like a person instead of a flyer, and use a reply-to a human actually reads. Reputation builds over a few weeks of normal sending — and a fresh subdomain starts colder than an established one, which is normal.
- I connected Mailgun and another email provider — which one sends?
- The one the 'Sends go through' picker in SiteOps Settings points at — an explicit choice, not a hidden rule. Several mailers can stay connected at once; only the picked one sends, and you can change it in the Email section whenever you like.