Mailgun
On this page
Connect CRM-NG SMTP to Mailgun with an API key, your verified sending domain and the matching US or EU region.
This guide shows you how to send your WordPress email through Mailgun, a developer-friendly transactional email service. It suits sites that want detailed logs and control, and businesses that need to keep data in the EU. Mailgun usually offers a free trial or a small free allowance; check its site for the current terms.
The Mailgun mailer sends through Mailgun's API. It needs three things that must agree with each other: an API key, the sending domain, and the region (US or EU) where that domain lives.
Before you start
- A Mailgun account (sign up at
https://www.mailgun.com/). Mailgun sends an activation email when you sign up; click the link in it before you go on. - A domain you control, with access to its DNS records. Mailgun suggests a subdomain such as
mg.yourdomain.com. - Administrator access to your WordPress site.
Step 1: Add and verify your sending domain
- Sign in to Mailgun
Go to
https://app.mailgun.com/and sign in. - Open the domains list
Open Send → Sending → Domains (the plugin's Get a Domain Name link goes there).
- Add a domain
Choose Add new domain and enter it, for example
mg.yourdomain.com. - Pick the region
Choose US or EU. You cannot move a domain between regions later, so pick EU if you operate under EU data rules.
- Publish the records
Mailgun lists TXT records for SPF and DKIM, plus optional MX and CNAME (tracking) records. Add them at your DNS provider.
- Verify
Press Verify DNS settings in Mailgun until the domain shows as verified.
The sandbox domain
Every new account gets a sandbox domain (it starts with sandbox). It only sends to recipients you add as authorised, so use it for a quick trial at most. Use your own domain for the live site.
Step 2: Create an API key
- Open API security
Open the account menu (top right) and choose API Security (the direct address is
https://app.mailgun.com/settings/api_security). - Add a key
In the Mailgun API Keys section, choose Add new key, give it a description such as your site name, and create it.
- Copy it
Copy the key now; Mailgun shows the full key once.
Step 3: Connect in CRM-NG SMTP
- Choose the mailer
In WordPress, open CRM-NG SMTP → Settings → General and set Mailer to Mailgun.
- Paste the key
Paste the key into Mailgun API Key.
- Enter the domain
In Domain Name, type the sending domain exactly as Mailgun lists it, for example
mg.yourdomain.com. Do not addhttps://or a trailing slash. - Pick the region
Under Region, choose US or EU to match the region you picked for the domain.
- Set the sender
Set From Email to an address on that domain (or its parent domain) and set From Name. Tick Force From Email if other plugins change the sender.
- Set Return Path
Tick Return Path so bounce messages go back to your From Email instead of being lost.
- Save
Press Save Settings.
Send a test email
Open CRM-NG SMTP → Tools → Email Test, enter your address in Send To, and press Send Email. In Mailgun, Send → Reporting → Logs (or the logs page for your domain) shows the result. See Sending a test email.
The domain check on the test page looks for mailgun.org in the SPF record of the domain in Domain Name. See Adding DNS records.
Troubleshooting
- Wrong key, a disabled key, or an account not yet activated: 401 Unauthorized or Forbidden
- The domain name or region does not match your account: 404 Not Found
- The key was mistyped: Invalid API key
- Mailgun disabled the account: Account blocked
- You have reached your plan or sandbox limit: Email sending limit reached
- The recipient bounced before and is blocked: Email address in suppression list
- Mail arrives in spam: Emails landing in spam
A 404 almost always means one of three things: the domain is typed differently from Mailgun's list, the region is wrong, or the domain belongs to another Mailgun account.
