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 using WP Mail SMTP.
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 SMTP services we recommend: Mailgun.
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 (or 100 emails per hour), 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 using WP Mail SMTP.
1. Sign up for a Mailgun account
First you need to sign up for an account on the Mailgun website.
Note: As an added verification step Mailgun will require that you enter credit card information to set up an account, even if using a free account. For more information, please see Mailgun’s sign up page.
After completing the short signup form, you’ll have a couple of additional verification steps to complete. 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 within this email in order to start the verification process.
After clicking the verification link, you’ll then need to enter a mobile number to receive a text verification code.
Once you’ve completed these steps, you’ll be logged directly 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.
On the Domains page, you’ll need to click the Add New Domain button.
Note: If you don’t see a button to add a new domain, this likely means that you have not yet entered a credit card. Mailgun requires all accounts, including free accounts, to enter a credit card before you can continue.
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 such as blog.example.com).
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 mail.yourwebsite.com or mg.yourwebsite.com. (It doesn’t really matter what you name it, but using “mail” or “mg” makes it more clear what its purpose is.)
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 the default US option.
Last, 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.
As we continue into the next step, be sure to keep this tab or window open as 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.
Note: If you’re 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 tutorial on DNS settings.
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 two 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.
In your site’s DNS settings you may also see a TTL field, or Time To Live. If provided the option, we recommend setting the TTL to one hour (or 3600 seconds, depending on the units your DNS uses).
Once you’ve added both TXT records, your DNS settings are all set.
Note: Mailgun will also show you MX and CNAME records, however you can ignore these as they are not relevant when only using Mailgun 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.
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.
After installing and activating this plugin, you need to visit Settings » WP Mail SMTP to configure plugin settings.
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.
You can also choose to check the box labeled Force From Email. If you’d like the From Email to be the same site-wide, this option 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. With this enabled, you’ll be emailed if any messages bounce as a result of issues with the recipient’s email.
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, you’ll need to click on the small circle with your initials. Then, select the Security option.
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.
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.
Then for the Domain Name, enter the subdomain you created in Mailgun (for example, mg.yourdomain.com).
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 Settings » WP Mail SMTP 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.
If you check the inbox for that email address, you should receive the email for this test.
Note: Be sure to also submit a couple of test submissions for your forms after completing this setup to check that emails deliver successfully.
If you see any issues, we recommend setting the From Email in your form’s notification settings to the same email you set up Mailgun with.
That’s it! You have successfully setup your site to send WordPress emails with Mailgun. Now your form notifications will reliably be delivered.
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.