How to Connect Mailgun to WordPress
The LetterPress Mailgun card uses its API, not SMTP. Choose the US or EU region where you created the sending domain.
Before you begin
- A Mailgun account.
- A sending domain added in Mailgun.
- A private API key or a domain sending key.
- The region where the domain was created, US or EU.
Step 1: Add and verify your domain
- Sign in to Mailgun.
- Open Sending > Domains and click Add Domain.
- Enter a subdomain such as
mg.example.com. A subdomain keeps your main domain separate. - Choose the US or EU region.
- Copy the DNS records Mailgun shows and add them at your DNS provider.
- Wait until Mailgun verifies the domain.
The region matters. A domain created in the EU region is not available through the US API.
Step 2: Get an API key
- Open Settings > API Keys.
- Copy a private API key, or create a new one.
Use a private API key for LetterPress. The connection test reads recent events, and a domain sending key may not have permission to read them.
Step 3: Enter the details in LetterPress
- Open Settings > Email providers.
- Select Mailgun.
- Paste the API key.
- Enter the sending domain, for example
mg.example.com. Do not includehttps://. - Choose the same region you used in Mailgun.
- Save changes. Set this provider as default if the button is shown. Then click Test connection.
The test reads recent events for the domain. It fails if the key cannot access the domain or the region is wrong.
Step 4: Set the sender and test
Open Settings > Sender identity and set From email to an address on the verified Mailgun domain.
Click Send test email. Then send a test email from Settings > Sender identity.
Common problems
| Problem | What to check |
|---|---|
401 Unauthorized | The API key is wrong or revoked. |
404 Domain not found | The domain name is misspelled, or the region does not match. |
403 Forbidden | The key cannot access this domain, or the domain is not verified. |
| Mail is accepted but not delivered | Check the Mailgun logs for a suppression or a recipient rejection. |
| Mail goes to spam | Finish domain verification and add SPF, DKIM, and DMARC. |
Next steps
- Connect Mailgun webhooks with event tracking.
- Review email authentication.
- Move an existing Mailgun setup with SMTP migration.