Sending
Connect Mailgun
Mailgun is a developer-friendly transactional email API. Two fields: your sending domain and an API key.
Overview
Mailgun organizes sending around domains. Every send is associated with a Mailgun domain, and the domain determines which DNS records Mailgun expects. Mailgun has two regional infrastructures: US (default) and EU. The EU region keeps data within Europe — use it if your recipients or your own data residency requirements demand it.
US vs EU — PICK CORRECTLY
region to euin Nudgel. Using the wrong region causes authentication errors even with a valid API key. The two regions have separate API endpoints (api.mailgun.net vs api.eu.mailgun.net).Get your credentials
- Log in to app.mailgun.com
- Go to Sending → Domains and confirm your sending domain is verified (or add a new one and follow the DNS instructions)
- Go to Settings → API Keys
- Create a new Sending API Key (not the Private API Key — that has broader permissions than you need)
- Note which region your domain lives in (visible on the domain list page)
Add the provider in Nudgel
- Go to Settings → Providers
- Click Add a provider
- Pick Mailgun
- Fill in the fields:
| Field | Required | Notes |
|---|---|---|
domain | Yes | Your Mailgun sending domain, e.g. mail.acme.co.ke. Must match the domain in your Mailgun account. |
from_email | Yes | Must be something@<your_mailgun_domain> |
from_name | Yes | Display name shown to recipients |
region | Yes | us or eu. Match the region where your domain was created in Mailgun. |
api_key | Yes | Mailgun Sending API Key. Encrypted at rest. |
Test the connection
curl -X POST https://api-raven-cloud.autotribes.app/v1/messages \
-H "X-Raven-Key: rk_live_a3f7b2c1_..." \
-H "Content-Type: application/json" \
-d '{
"channel": "email",
"to": "you@example.com",
"from": "noreply@mail.acme.co.ke",
"subject": "Nudgel test — Mailgun",
"bodyHtml": "<p>If you can read this, Mailgun is wired up.</p>",
"bodyText": "If you can read this, Mailgun is wired up."
}'Check Mailgun → Logs (under your domain) to confirm the message was accepted.
Set up webhooks
Configure webhooks in Mailgun → Sending → Webhooks. You can set different URLs per event type, but the simplest setup is one URL for all events.
Set the URL to:
https://api-raven-cloud.autotribes.app/v1/webhooks/email/mailgun/{YOUR_TENANT_ID}Enable: Delivered, Permanent failure (hard bounce), Complained (spam), Unsubscribed. Hard bounces and spam complaints auto-add to your suppression list. See the webhooks guide.
Verify your sending domain at Mailgun
To send from your own domain (e.g. mail.example.co.ke) through Mailgun, publish DKIM records Mailgun generates for you. Nudgel orchestrates this from one dashboard.
- In Nudgel dashboard, go to
Settings → Sending domains → Add domain, enter your domain. - On the next screen, select Mailgun. Nudgel calls Mailgun's domain registration API using your credentials and shows you the DNS records to publish.
- Publish the records at your DNS host (Cloudflare, Route 53, etc.).
- Nudgel polls every 30 seconds for the first 10 minutes, then hourly. Verification surfaces in the dashboard automatically.
Add this to your SPF record
include:mailgun.org to your existing SPF record (or create a new v=spf1 include:mailgun.org -allif you don't have one).Mailgun-specific notes
- US and EU regions are independent — always verify the domain in the region matching your Nudgel provider config. A domain verified in EU is not visible from the US API.
- Mailgun returns three record types for a verified domain: a DKIM TXT, an SPF TXT, and a tracking CNAME. Publish all three.
Full setup walkthrough: Sending domains setup
Troubleshooting
| Symptom | Most likely cause |
|---|---|
failed — "Forbidden" / 403 | API key is wrong, or you set the wrong region. A US key does not work against the EU endpoint and vice versa. |
failed — "Domain not found" | The domain field does not match a domain in your Mailgun account. Check spelling and region. |
failed — "From address does not match domain" | The from_email domain must match the Mailgun domain you configured. |
failed — "Domain is unverified" | Your Mailgun domain has not passed DNS verification. Check the DNS records in Mailgun → Sending → Domains → [domain] → DNS records. |
| Emails land in spam | Ensure your Mailgun domain is fully verified (all DNS records green). See sending domains. |