Configure Mailgun for WordPress

Most WordPress hosts, including WP Engine, limit a website’s email usage because web hosting servers are not optimized for sending email. Email is better served when sent from a specialized email server. This allows the email provider and website manager to govern spam, view logs, and ensure deliverability.

Mailgun is a popular email relay service to help ensure emails are delivered to recipients. In this article, learn how to configure Mailgun and the Mailgun WordPress plugin to help improve email deliverability.


Sign Up with Mailgun

The first step to configuring Mailgun is to sign up for an account. Mailgun is free for the first 5,000 emails every month, making it a great cost-friendly option for websites that don’t send a massive amount of email.

Sign up for Mailgun here.

After signing up, verify the account via email and text message. After the account is verified, the domain can be added to Mailgun.


Add Domain

  1. Once logged in to Mailgun’s dashboard, click Add Domain.
  2. Choose a domain (or subdomain, preferably) for sending mail through the website.
    • This example uses the “mail” subdomain of the top-level domain (mail.areallycoolwebsite.club).
  3. Mailgun will then provide records which need to be added to the domain’s DNS.
    • Leave this page open in a separate tab to easily copy the information in the next step.

Add and Verify DNS Records

Copy the records listed in Mailgun’s configuration page into the DNS provider’s dashboard. This example domain is managed through Namecheap, so this is where the Mailgun DNS mail records were added.

Once the records have been added, verify the records have been successfully configured on the Mailgun Domains page. Scroll down and click “Domain Verification & DNS” to check whether the records were successfully configured (remember: these records can take up to 24 hours to propagate).


Install and Activate Mailgun

Log in to the WordPress Admin Dashboard for the following steps. Additionally, log in to the website’s WordPress Admin Dashboard.

  1. Navigate to Plugins > Add New and type “Mailgun” to locate the Mailgun for WordPress plugin.
    • The plugin is both named “Mailgun” and will show “Mailgun” as the author.
  2. Once the Mail plugin is installed, activate the plugin on the same screen.
  3. Then, configure Mailgun from the Settings > Mailgun section.

Configure Mailgun

Once on the Mailgun plugin Settings page, enter some important settings from the Mailgun portal.

  1. Ensure “Yes” is selected for the Use HTTP API setting.
    • This ensures that mail will be relayed over the Mailgun API, instead of using an SMTP port. The API setting is more reliable, and works even when normal mail ports are closed.
  1. Enter the domain configured for use with Mailgun in the Mailgun Domain Name field.
  2. Enter the API Key from the Mailgun Domains page, then continue to set any other preferences before saving.
  3. After saving, send a test email to ensure the settings were configured properly.
    • If there are errors, it could mean the DNS settings are still propagating, or that the settings are misconfigured–make sure the Mailgun domain also shows “Active.”
    • If the email is sent successfully, a test email should arrive with the following text:
    • This is a test email generated by the Mailgun WordPress plugin. If you have received this message, the requested test has succeeded. The method used to send this email was: HTTP API.

Send Emails with WordPress

Now that the Mailgun settings are configured and tested:

  • WordPress emails (like password resets, etc.) are automatically sent through Mailgun.
  • Other plugins that send email through WordPress, like Contact Form 7 or Gravity Forms, will use Mailgun.
  • Newsletters or other mass communications to site users will use Mailgun.

Be aware, Mailgun account is free up to a certain number emails. Beyond that, review the Mailgun pricing page.

Track email deliverability, as well as statistics (accepted, delivered, bounced, opened, clicked, etc) from the Mailgun Logs area.


NEXT STEP: How to use DMARC policies to ensure emails can be delivered

Still need help? Contact support!

We offer support 24 hours a day, 7 days a week, 365 days a year. Log in to your account to get expert one-on-one help.

The best in WordPress hosting.

See why more customers prefer WP Engine over the competition.