How to Send WordPress Emails With Mailgun Using WP Mail SMTP

Have you noticed that you’re not receiving WordPress contact form notifications?

You might be wondering why WPForms isn’t sending you emails when someone fills out your forms, or why you aren’t seeing any WordPress notifications.

In this tutorial, we’ll walk you through how to fix email delivery issues and send WordPress emails with Mailgun using WP Mail SMTP.

What Causes Missing WordPress Emails

Maybe you’ve noticed that WordPress isn’t sending you email notifications because form entries are piling up in your WordPress dashboard. Or, frustrated visitors have reached out to you using social media or other methods about not hearing back from you.

In most cases, missing WordPress emails is due to spam prevention.

As spammers get smarter, email providers have to keep bulking up their spam defenses. This is normally the most common cause for missing emails.

spam blockers fix by send WordPress emails with Mailgun

In some other cases, missing emails is due to your WordPress hosting server not being configured to use the PHP mail() function. Even if it’s unmanaged or managed WordPress hosting. That function is used by WordPress by default to send emails generated by WordPress or any contact plugin like WPForms.

Thankfully, you can work around both of these issues by using SMTP.

SMTP (Simple Mail Transfer Protocol) is the industry standard for sending emails. Unlike PHP mail function, SMTP uses proper authentication which increases email deliverability. That’s why we recommend using SMTP to send emails in WordPress.

In this article we’ll show how to do this with one of the SMTP services we recommend: Mailgun.

You can also check out our articles on how to send emails with Gmail or Sendgrid.

How to Fix Your Form Notifications with Mailgun + WP Mail SMTP

Mailgun is a popular email service provider that allows website owners to send tons of emails.

You can send your first 5,000 emails for free every month. If you’d like to send more emails than that, you’ll need a paid plain.

So let’s get started setting up your site to send WordPress emails with Mailgun using WP Mail SMTP.

1. Sign up for a Mailgun Account

First, you need to sign up for an account on the Mailgun website.

sign up for a mailgun account page

Note: As an added verification step, Mailgun will require that you enter credit card information to set up an account, even for the free account. For more details, please see Mailgun’s sign up page.

After completing the short signup form, you’ll have a couple of additional verification steps to do. Multiple levels of verification is what allows Mailgun to better ensure email deliverability for all of their users.

First, you should receive an email to verify your Mailgun account. You’ll need to click the link in this email to start the verification process.

mailgun support message

After clicking the verification link, you’ll need to enter a mobile number to receive a text verification code.

mailgun account verification screen send WordPress emails with Mailgun

Once you’ve completed these steps, you’ll be logged into Mailgun.

Now that you’re logged in, you should see your Mailgun dashboard. When you’re ready, click on Domains in the left menu.

add new domain mailgun settings

On the Domains page, you’ll need to click the Add New Domain button.

add new domain mailgun settings

Note: If you don’t see a button to add a new domain, this likely means that you have not yet entered your credit card details. Mailgun requires all accounts, including free accounts, to enter a credit card before you can continue and send WordPress emails with Mailgun.

Next, you’ll need to enter a subdomain of your website’s domain name.

What does that mean, exactly?

A subdomain replaces the “www” part of your website’s address; for example: “” Subdomains can be used to add separate sections or directories to your website (like how some sites have their blogs on a subdomain such as

In this case, the subdomain will be used by Mailgun to send emails.

We’ll create the actual subdomain in the next step. For now, you can just enter a subdomain such as or It doesn’t really matter what you name it, but using “mail” or “mg” makes it more clear what its purpose is.

add domain to send mail with mailgun

Next, you’ll need to choose US or EU. If your site is hosted in the European Union, then go ahead and choose EU. If your site is hosted anywhere outside of the European Union, then leave it on the default US option.

smtp mailgun domain settings

Lastly, we recommend keeping the Create DKIM Authority box checked for an extra mode of spam protection.

We also recommend selecting the 2048 option, which creates a longer DKIM key.

dkim auth

As we continue into the next step, be sure to keep this tab or window open because we’ll return to this page later.

2. Verify Your Domain

As a way of both protecting site owners and their visitors, some SMTP services like Mailgun require that you verify your domain by adding records to your site’s DNS. You can find more information on the benefits of verifying your domain in Mailgun’s guide.

First, you’ll need to open your site’s DNS settings. If you’re not sure how to find these, Mailgun will provide you with some helpful links shown on their setup page when you’re adding a new domain.

dns records for sending mailgun smtp

Note: If you’re still not sure where to find your site’s DNS settings or feel unsure about making changes, please contact your site’s hosting provider.

Or for more details on modifying a site’s DNS, we recommend WPBeginner’s DNS settings tutorial.

Once your DNS settings are open, you should see an option to add a new record.

To make it possible for Mailgun to verify your domain, you’ll need to add 2 TXT records to your site’s DNS. Be sure to copy them carefully, as you’ll need the exact values from your Mailgun account for the verification to work.

dns records for sending mailgun smtp

DNS managed by GoDaddy? You’ll need to adjust the Hostname in Mailgun. When entering the Hostname into your GoDaddy DNS, you’ll need to remove your normal domain. For instance, instead of entering for the first TXT record’s Hostname, you will only enter mg.

In your site’s DNS settings you may also see a TTL (Time To Live) field for the record. We recommend changing the TTL to one day (or 86400 seconds, depending on the units your DNS uses).

Once you’ve added both TXT records, you’ll need to add MX records in exactly the same way. Just remember that you need to do this for the subdomain you created — not for the main domain.

Now that you’ve added both TXT and MX records, your DNS settings are all set.

Note: Mailgun will also show you a CNAME record, but you can ignore this as it’s not relevant when using Mailgun only to send emails.

3. Check your Mailgun Verification Status

Now Mailgun will need to verify that your domain has proper DNS records. This verification can take a while (sometimes 24-48 hours) because DNS records may take some time to update.

You can check the status of your domain verification any time by visiting the Domains page in your Mailgun account. Once Mailgun can verify the DNS changes you made, it will show a green check mark next to your domain name.

mailgun verification settings smtp

However, you can skip to the next step while you wait for this verification to complete. Just be sure to keep this tab or window open, as we’ll need it a little later.

4. Configure WordPress to Send Emails

Now that you’ve set up your DNS, you can prepare your WordPress site to start using Mailgun with WP Mail SMTP for sending emails.

The first thing you need to do is install and activate the WP Mail SMTP plugin. For more details, see our step by step guide on how to install a WordPress plugin.


After installing and activating this plugin, you need to navigate to WP Mail SMTP » Settings to configure the plugin settings.

wpmailsmtp plugin settings in dashboard

At the top of this page, you can set the From Email and From Name. By default, these will fill with your site’s admin email and site name.

For the From Email, you can use any valid email address.

We strongly recommend that you also check the box labeled Force From Email. Since the From Emails from anything on your site that sends email must match this email address in order for SMTP to work, this will save you the trouble of editing the email settings throughout your site (in all form emails, etc).

You may add any From Name you’d like, and you can also choose to Force From Name to apply this setting site-wide.


Next, in the Mailer field you’ll need to select the Mailgun option.

We also recommend checking the optional Return Path checkbox to Set the return-path to match the From Email. This will send you an email if any messages bounce as a result of issues with the recipient’s email address.


After selecting Mailgun as your mailer, a new Mailgun section will appear. Here, you’ll need to enter API and domain information.

Even if your domain is still waiting to be verified, Mailgun will provide this information. You may even have automatically received an email containing your API key, otherwise you’ll need to return to the tab or window with your Mailgun domain details.

In the upper right corner of your Mailgun account, click on the small circle with your initials. Then, select the Security option.

mailguin security page

This will take you to a page that includes your API key. You’ll need to click the eye icon to view your full API key.

api key page in mailgun

Once you’ve copied the text for the full key (including key- at the start), return to the WP Mail SMTP settings and paste it into the API Key field.

mailgun private api key page

Then for the Domain Name, enter the subdomain you created in Mailgun (for example,

Once this information is complete, go ahead and save your settings.

5. Send a Test Email

Note:Before proceeding with this step, make sure that the verification process from Step 3 is complete. This may take a while, so it’s possible you’ll need to come back to this later.

Once your domain is verified and your settings have been added to WP Mail SMTP, it’s important to send a test email to ensure that everything is working properly. To do this, make sure you’re on the WP Mail SMTP » Settings page and open the Email Test tab.

On this tab, you can enter any email address that you have access to and click the Send Email button.

After sending the email, you should see a success message.

test email was sent successfully

If you check the inbox for that email address, you should receive the email for this test. If you set up WordPress email logs, you can look there as well.

confirmation of successful test email send WordPress emails with Mailgun

It’s also a good idea to fill out a couple of test submissions for your forms after completing this setup to check and make sure that emails are being delivered successfully.

Final Thoughts

That’s it! You have successfully set up your site to reliably send WordPress emails with Mailgun.

Looking for more email notification tips? You might also want to reassure visitors that their form entries have been received by checking out how to send users confirmation emails from WordPress forms.

So what are you waiting for? Get started with the world’s most powerful WordPress forms plugin today.

And if you like this article, then please follow us on Facebook and Twitter for more free WordPress tutorials.

Using WordPress and want to get WPForms for free?

Enter the URL to your WordPress website to install.


  1. Thanks for the documentation. If I may suggest one part to add and highlight because it gave me issues:

    The API key includes “key-.” I know it’s dumb that I missed it, but I didn’t copy the “key-” bit, and that obviously caused an error. I double-clicked on the second part of the API key to select it, and that doesn’t grab the whole thing because of the dash.


    1. Thanks for mentioning that, Stanford — we revised the text for that instruction slightly, hopefully that helps! 🙂

  2. Why would anyone want to use WP Mail SMTP in addition to Mailgun? The whole point of Mailgun is so that you don’t need WP Mail SMTP – or SMTP mail at all, for that matter!

    1. Hi Peter,

      Great question. To be used on a WordPress site, a Mailgun account must be connected via a plugin such as WP Mail SMTP. This is where the API details get added so that Mailgun can be applied to your site — without that, your Mailgun account can’t connect to your WordPress site and so would have no influence over emails sent there.

      I hope that helps! 🙂

  3. Check your other plugins for conflicts. I had a conflict issue with an old Sendgrid plugin and some configurations in mail poet.

    1. Thanks, Elise! Having more than one SMTP plugin active on your site is very likely to cause issues/break SMTP functionality, so that’s a great suggestion to check.

  4. Hi

    I do not receive emails from my WPForms.
    I have added Mailgun, and WP Mail SMTP, and have received email from both, that they are ok.

    I have the same email-address in Mailgun, WPForm and in WP Mail SMTP.
    What am I doing wrong?


      1. Hi 🙂

        I have only the WPForms lite, so I do not have the login information i need, to make a support request. What do I do then?

  5. Hello,

    I use WPFormsLite for my Contact Form (in conjunction with WP Mail SMTP and Mailgun). But I use MailerLite for my newsletters and subscription forms, etc. Do these interfere with each other? Or are they completely separate methods of transmitting email for completely different reasons?

    I want to maintain speedy performance of my site as best I can. But I’m pretty new to this so don’t quite understand the details.

    Thank you for any clarification you can provide!

    1. Hi Marie – Sorry for my late response here! WP Mail SMTP will help with any emails that get sent out from your WordPress site & use the standard WordPress email sending functionality (rather than something custom, which is unusual).

      A marketing service like MailerLite should be sending out emails from their own servers, completely separate from your own site emails and anything WP Mail SMTP would impact.

      I hope this helps!

  6. Why do I have to send mails form a subdomain. Can I not just do it with a Gmail account?
    Also, the Texts and MX records informations are given by Mailgun while verifying the domain?

    1. Hey Jose – That is how Mailgun works, they verify your domain ownership and allow to send emails via one of your subdomains. They might have some other alternatives like you mentioned, I would suggest contacting their support for more confirmation on this.

      Yes, those TXT and MX record values will be provided to you by Mailgun, you just need to enter those in your website cPanel as instructed in their tutorials.

      I hope this info helps!

  7. I set up Mailgun but for some reason the Admin isn’t getting emails when a user signs up for a new account. She’s hosted on Bluehost and her emails are thru Office 365 on GoDaddy. I created all the necessary records and installed Mailgun yet nothing is coming in to the Admin.

    Emails go to the users just not the admin. What am I missing?

    1. Hey there – Sorry to hear that you are facing trouble with WP Mail SMTP with Mailgun. I would suggest creating a support ticket with them.

      If you have a paid license of WP Mail SMTP, you can reach out to them here or if you are a free user, you can reach out to them here. Have a good one 🙂

  8. do you have an option to configure network wide via constants but also allow a single site to override the network settings.?

    1. Hi Michael- Great question! You can only configure the plugin Network-wide or on a single site. Both the options can’t be configured at a time!

      Hope that helps! 🙂

  9. You certainly do NOT need the WP Mail SMTP plugin to configure Mailgun. You simply install the Mailgun plugin on its own and you are done.

    1. Hi Felix! You’re certainly correct that WP Mail SMTP isn’t needed to use Mailgun on WordPress sites, nor does this article aim to say that. This article is a guide to setting up the Mailgun SMTP service with the WP Mail SMTP plugin. Both the Mailgun plugin and free version of WP Mail SMTP would essentially do the same things, though the WPMS plugin would have greater flexibility in that it allows for setting up of other mailers, while the Mailgun plugin is specific to Mailgun service only.

      If you have any further questions about this, please feel welcome to submit a support ticket, If you have a WP Mail SMTP license.
      Otherwise, we provide limited complimentary support in the WP Mail SMTP support forum.


Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.