Skip to main content

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​

  1. Sign in to Mailgun.
  2. Open Sending > Domains and click Add Domain.
  3. Enter a subdomain such as mg.example.com. A subdomain keeps your main domain separate.
  4. Choose the US or EU region.
  5. Copy the DNS records Mailgun shows and add them at your DNS provider.
  6. 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​

  1. Open Settings > API Keys.
  2. 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​

  1. Open Settings > Email providers.
  2. Select Mailgun.
  3. Paste the API key.
  4. Enter the sending domain, for example mg.example.com. Do not include https://.
  5. Choose the same region you used in Mailgun.
  6. 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​

ProblemWhat to check
401 UnauthorizedThe API key is wrong or revoked.
404 Domain not foundThe domain name is misspelled, or the region does not match.
403 ForbiddenThe key cannot access this domain, or the domain is not verified.
Mail is accepted but not deliveredCheck the Mailgun logs for a suppression or a recipient rejection.
Mail goes to spamFinish domain verification and add SPF, DKIM, and DMARC.

Next steps​