WordPress Tutorials, Tips, and Resources to Help Grow Your Business
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 by sending WordPress emails with Mailgun.
Why Email Notifications Don’t Work
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 start to reach out to you using social media or other methods.
The most common reason for missing these emails is due to your WordPress hosting server. Usually it isn’t configured to use the PHP mail() function, which WordPress uses by default to send emails generated by WordPress or any contact plugin like WPForms.
Thankfully, you can work around this issue 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 one of the many SMTP services we recommend: Mailgun. If you want to learn about the pros and cons of other ways to fix this problem, visit How to Fix WordPress Contact Form Not Sending Email With SMTP.
How to Fix Your Form Notifications
Mailgun is a popular email service provider that allows website owners to send large quantities of emails. You can send your first 10,000 emails for free every month, though beyond that it’s a paid service. But that’s more than enough for most small websites.
Let’s get started setting up your site to send WordPress emails with Mailgun.
1. Sign up for a Mailgun account
First you need to signup on the Mailgun website. Mailgun will prompt you to add a domain right when you sign up, though this can also be accessed by logging into Mailgun and going to Domains, then clicking the Add New Domain button.
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: “subdomain.yourwebsite.com.” Subdomains can be used to add separate sections or directories to your website (like how some sites have their blogs on a subdomain like blog.example.com).
In this case, the subdomain we’ll create 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 mail.yourwebsite.com. (It doesn’t really matter what you name it, but using “mail” makes it clear what its purpose is.)
Keep the Mailgun page open in your browser as we continue with the next step.
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 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.
Once you’re in your DNS settings, you should see an option to add a new record. Mailgun will require you to enter two TXT records, which they also list on their setup page. Here’s an example of what this section should look like if you’re on Mailgun’s site:
The first record you’ll need to add is for SPF, or Sender Policy Framework, which is the way that most email providers will verify your domain:
- Type: TXT
- Value: “v=spf1 include:mailgun.org ~all”
You may also see a TTL, or Time To Live, field for the record. This indicates how long this DNS record should be cached before it gets refreshed. You can leave this blank to allow the default TTL value to be used.
Instead of SPF, many other email providers will use DKIM. DKIM serves the same purpose as SPF but uses cryptographic methods. To make it possible for these services to also verify your domain you’ll need to add a second TXT record. However, the value of this record will be specific to your Mailgun account.
The next step is to add MX, or Mail Exchanger, records. MX records are what note how email should be handled. This is recommended to ensure successful delivery unless you have a specific reason not to do so.
Mailgun’s MX records are the same for everyone:
First MX record:
- Type: MX
- Priority: 10
- Value: “mxa.mailgun.org”
Second MX record:
- Type: MX
- Priority: 10
- Value: “mxb.mailgun.org”
If you’d like to use Mailgun to track events and statistics for messages, you’ll can choose to add one more DNS record: a CNAME. You can read more about the type of tracking Mailgun offers in their documentation here, and the custom CNAME record is available on your Mailgun account below the MX records.
Once you’ve completed these steps, your DNS settings are good to go.
5. 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 by visiting Domains page in your Mailgun account.
Once Mailgun can verify the DNS changes you made, it will show active status next to your domain name.
However, you can skip to the next step while you wait for this verification to complete.
6. Configure WordPress to Send Emails
Now that you’ve set up your DNS, you can prepare your WordPress site to start using Mailgun for sending emails.
Upon activation, you need to visit Settings » Mailgun to configure plugin settings.
By default, Mailgun sends emails by using a method called “HTTP API,” as you can see in the first option. This is the recommended method so you can leave it as the default. But if for some reason it doesn’t work on your website, then you can switch to SMTP and see if that works.
You will need your Mailgun API keys. Simply login to Mailgun dashboard and click on your domain name. Mailgun will show your SMTP credentials as well as API key.
You need to copy and paste those keys into plugin settings and click on the save changes button.
After storing your settings you can click on the test configuration button. Mailgun will test your settings and will show you a success message.
That’s it! You have successfully setup your site to send WordPress emails with Mailgun. Now your form notifications will reach your email inbox.
Looking for more email notification tips? You might also want to check out our guide on how to send users confirmation emails from WordPress forms. This is a great way to reassure visitors that their message has been received, and prevent them from sending duplicates.
Don’t have WPForms yet? What are you waiting for? Get started with the most powerful WordPress forms plugin today.