How to Connect Mailgun to Your WordPress Website
In order for your WordPress website to reliably send emails (such as contact form notifications, user registrations, etc) you need to configure WordPress to use an SMTP provider. In this article, we’ll show you how to set up Mailgun SMTP. Step 1: Create a Mailgun Account Head over to mailgun.com and create your account. You’ll…
By George Leon | Updated July 5, 2022
In order for your WordPress website to reliably send emails (such as contact form notifications, user registrations, etc) you need to configure WordPress to use an SMTP provider.
In this article, we’ll show you how to set up Mailgun SMTP.
Step 1: Create a Mailgun Account
Head over to mailgun.com and create your account. You’ll be asked for your credit card information, but you won’t be charged anything. Select the ‘Flex Plan’ which allows up to 6000 emails sent per month.
Mailgun needs your card on file in case you ever go over that amount, but even then, it’s really inexpensive. And most small businesses will never send anywhere near that amount in a single month.
After creating your account, Mailgun will send you an email with a link to verify your account. You may also be asked to verify your account with your mobile phone number.
Step 2: Add a Domain in Mailgun
After logging in to Mailgun, go to the side panel, click on the Sending tab to open the dropdown, and select Domains.
From here, click on Add New Domain.

On the next page, enter your domain but with the mg. prefix like in the example below:

Select your region, and select a DKIM key length. I like to use 2048 for extra security against spammers.
Step 3: Add DNS Records to Your Domain
After adding your domain, Mailgun will show you a page with a list of 5 DNS Records like in the example below:

Go to your Domain’s DNS provider. For most people, that means their domain registrar such as Godaddy, Google Domains, Namecheap, etc. But if you use a separate DNS service such as Cloudflare to manage your DNS records, go there.
Whether you manage your DNS records at your domain registrar or a separate DNS service, you’ll want to find the page where you can edit your DNS records.
When you’re at your DNS records page, just add the 5 DNS records from Mailgun and save.
If you’re using Google Domains, you should watch this video because adding the 2 MX records is a little different on Google Domains than in most other places.
If you’re using Cloudflare, watch this video for step-by-step instructions.
If you’re using something else, those above videos might still be helpful. Or you can search on youtube for Mailgun + your registrar.
Step 4: Connect Your Mailgun Account to Your WordPress Website
Go to your WordPress dashboard. Hover over the Plugins tab and click on Add New. Then search for WP Mail SMTP. The first result should be WP Mail SMTP by WPForms, click on the Install Now button, then Activate.

Now you should see a new tab on your WordPress dashboard titled WP Mail SMTP. Click on it.

Now you will see a few fields you need to fill out.
You can skip the License Key field because you don’t need the Pro version of this plugin for it to work.
On the From Email field, enter an email address at your domain. It does not have to be an actual email address you’ve created. You can use something like hello@yourdomain.com. Then enter a name on the From Name field. It can be your name or your business’s name.
Enable the Return Path option if you want to receive notifications of non-delivery receipts.
On the Mailer options, select Mailgun.
Now you will need to enter your Mailgun API Key. In order to get it, go back to your Mailgun dashboard. Click on your profile icon in the upper right corner. From the dropdown options, click on API keys.

Now click on the Eye icon to view your Private API Key. Then copy the revealed API key to your clipboard

Now go back to WordPress and paste this API key in the Private API Key field.
Enter the domain you set up on Mailgun (it should start with mg.). Then, select your region.
Then click on the Save Settings button.

And that’s it. You can click on the Email Test tab to send a test email. Or just go try using your contact forms and see if they send an email properly.
When you receive an email from your website, you should be able to click on the dropdown next to the recipient name (If you’re using Gmail) and see your Mailgun domain as the mailed-by and signed-by emails.

Do you just want us to take care of all your website needs such as this SMPT stuff, security, updates, hosting, CDNs, SSLs, and edits/changes to your website? Contact us to learn more about our managed hosting & maintenance plans.
Written by George Leon

George Leon is a Managing Partner at Scalebloom. George loves to help business owners scale their businesses with modern marketing strategies and branding.