Mailgun Setup Guide
Connect Mailgun to FormBlade for powerful email delivery with detailed analytics and routing rules.
Recommended for: Users on a paid Mailgun plan who need advanced features like email routing, log retention, and dedicated IPs. Also good for users who already have a verified domain with Mailgun.
Not recommended for: Users looking for a hassle-free free tier. Without a credit card, Mailgun restricts sending to only 5 whitelisted recipients — making it impractical for real form notifications. If you need a free provider, use Brevo instead.
⚠️ Critical free tier limitation: Without adding a credit card to your Mailgun account, you can only send to 5 whitelisted email addresses that you manually authorize. This means form submissions can only trigger notifications to those 5 addresses. Adding a credit card (even without upgrading) unlocks sending to anyone at 100 emails/day.
Free tier details
| Feature | Without credit card | With credit card (no paid plan) |
|---|---|---|
| Daily sending limit | 100 emails/day | 100 emails/day |
| Recipients | 5 whitelisted only | Anyone |
| Custom domain | Required | Required |
| Log retention | 1 day | 1 day |
| Sandbox domain | Yes (5 recipients) | Yes (5 recipients) |
Step 1: Create a Mailgun account
- Go to signup.mailgun.com
- Sign up with your email address
- Confirm your email address via the verification link
- Optional but recommended: Add a credit card under Billing to remove the 5-recipient restriction
Step 2: Add and verify a custom domain
Mailgun gives you a sandbox domain for testing, but it only sends to authorized recipients. For production use, you need to verify a custom domain.
- In the Mailgun dashboard, go to Sending → Domains
- Click Add New Domain
- Enter a subdomain dedicated to sending (e.g.,
mail.yourdomain.comormg.yourdomain.com). Using a subdomain is recommended so it does not interfere with your main domain's email - Mailgun will display DNS records you need to add:
Required DNS records
| Type | Purpose | Example name |
|---|---|---|
TXT | SPF record | mg.yourdomain.com |
TXT | DKIM record | smtp._domainkey.mg.yourdomain.com |
MX | Inbound routing (required even for sending-only) | mg.yourdomain.com |
The exact record values are shown in the Mailgun dashboard after you add your domain. Add all records at your DNS provider, then:
- Go back to Sending → Domains in Mailgun
- Click Verify DNS Settings on your domain
- Wait for the records to propagate (usually 5–30 minutes, can take up to 48 hours)
- All three records should show green checkmarks when verified
⚠️ Sandbox domain limitations: The sandbox domain (
sandboxXXXXX.mailgun.org) that Mailgun provides by default can only send to email addresses you explicitly authorize. Go to Sending → Domains → your sandbox domain → Authorized Recipients to add addresses. This is fine for testing but not for production.Step 3: Get your API key
- In the Mailgun dashboard, click your avatar in the top-right corner
- Go to API Security (or navigate to app.mailgun.com/settings/api_security)
- Your Private API Key is listed at the top (it starts with
key-) - Click the eye icon to reveal it, then copy it
Tip: Mailgun also offers domain-specific "Sending API Keys" under each domain's settings. These are scoped to a single domain and are more secure. Either the private API key or a domain sending key will work with FormBlade.
Step 4: Configure FormBlade
- Log in to your FormBlade dashboard
- Open the form you want to configure
- Go to the Settings tab
- Under Email Provider, select Mailgun
- Paste your API key into the API Key field
- Set your From Email to an address on your verified domain (e.g.,
forms@mg.yourdomain.com) - Optionally set a From Name
- Click Save
Step 5: Send a test email
- Click Send Test Email in the Email Provider section
- Check your inbox for the test notification
- If it fails, verify that your domain is verified, your API key is correct, and the recipient is not restricted by the 5-address limit
Troubleshooting
"Forbidden" or "401 Unauthorized" error
- Double-check the API key. Make sure you copied the Private API Key from API Security, not a domain verification code
- Check for extra spaces before or after the key
"Domain not found" error
- The "From Email" domain must match a verified domain in Mailgun
- If you verified
mg.yourdomain.com, the from address must be on that exact subdomain (e.g.,forms@mg.yourdomain.com), not the root domain
Emails only sending to some addresses
- If you do not have a credit card on file, Mailgun restricts sending to 5 whitelisted recipients
- Add a credit card at Billing → Payment Methods in the Mailgun dashboard to remove this restriction
- If you are still using the sandbox domain, switch to a verified custom domain
Emails going to spam
- Make sure all three DNS records (SPF, DKIM, MX) are verified. Missing records significantly hurt deliverability
- Use a subdomain for sending (e.g.,
mg.yourdomain.com) to protect your main domain's reputation - Ensure the "From Email" domain matches your verified Mailgun domain
No delivery logs
- The free tier retains logs for only 1 day. If you need to investigate delivery issues, check within 24 hours of sending
- Paid plans offer up to 30 days of log retention
Mailgun free tier summary
- 100 emails/day — sufficient for low-traffic forms
- 5 recipients without credit card — the biggest catch. Add a credit card to remove this limit
- Custom domain required — sandbox domain is for testing only
- 1-day log retention — paid plans get longer retention
- DNS verification required — you must add SPF, DKIM, and MX records
For most users who want a free email solution, Brevo is a simpler choice with fewer restrictions. Mailgun shines on paid plans where you get access to advanced routing, analytics, and higher volume.
Common gotchas
- 5-recipient limit without a credit card — This is the biggest surprise for new Mailgun users. Without a credit card on file, you can only send emails to 5 manually whitelisted addresses. Add a credit card (you will not be charged unless you upgrade) to remove this restriction.
- Custom domain is required for production — The sandbox domain (
sandboxXXXXX.mailgun.org) is for testing only and limited to authorized recipients. You must verify a custom domain to send to arbitrary recipients. - Use a subdomain for sending — Always verify a subdomain like
mg.yourdomain.comormail.yourdomain.comrather than your root domain. This protects your main domain's sending reputation and avoids conflicts with existing email (MX records). - Three DNS records required — Mailgun needs SPF (TXT), DKIM (TXT), and MX records. All three must be verified. The MX record is required even if you are only sending (not receiving) email through Mailgun.
- Private API key vs. domain sending keys — The Private API Key (found under API Security) works for all domains. Domain-specific sending keys (found on each domain's settings page) are scoped to that one domain and are more secure. Either will work with FormBlade.
- 1-day log retention on free tier — Free accounts only retain delivery logs for 24 hours. If you need to troubleshoot a delivery issue, check the logs within a day of sending.
- EU vs. US region — When creating your Mailgun account, you may be asked to choose a region (US or EU). This affects your API endpoint. Make sure your API calls go to the correct region. FormBlade handles this automatically based on your API key.
Quick reference: where to find things in Mailgun
| What you need | Where to find it |
|---|---|
| Private API Key | Click your avatar (top-right) → API Security, or go to app.mailgun.com/settings/api_security |
| Domain Sending Keys | Sending → Domains → click your domain → Sending API Keys |
| Domain verification | Sending → Domains → click your domain → DNS records |
| Authorized recipients (sandbox) | Sending → Domains → sandbox domain → Authorized Recipients |
| Billing / credit card | Click your avatar (top-right) → Billing |
| Sending logs | Sending → Logs |
Official documentation: For the latest on Mailgun's API, domain verification, and account limits, visit the Mailgun Documentation and the Messages API reference.