Introduction
Sending emails is a pillar of the smooth running of a WordPress site: contact forms, admin notifications, WooCommerce emails, password resets... Yet in many cases, emails sent by WordPress never reach their destination or end up in spam.
Mailgun is one of the most reliable SMTP services for sending transactional e-mails. Used by many high-volume platforms, it offers excellent deliverability, stability and advanced tracking tools, while remaining relatively simple to set up.
In this tutorial, we'll look at how to configure Mailgun as SMTP server on WordPress with WPMasterToolKit. From creating a Mailgun account to configuring the SMTP Mailer module, each step is explained step-by-step, enabling you to set up a reliable, secure e-mailing system that's perfectly suited to a WordPress site in production.
Whether you're running a showcase site, a blog or a WooCommerce site, this guide will help you avoid deliverability problems and get back on track with your WordPress emails.
What is Mailgun?
Mailgun is a transactional e-mailing service renowned for its reliability and ability to handle very large volumes of e-mail. It is based on a secure API and offers a free 3-month trial period.
Mailgun may take a little longer to set up than some other SMTP services. On the plus side, these extra steps mean you'll get high, stable deliverabilityThis makes it a particularly reliable solution for WordPress sites in production.
Cost
A free account, without a bank card, is limited to sending to 5 authorized recipients and allows you to send up to 5,000 e-mails per month for 3 months. Beyond that, rates start at 0.80 $ for 1,000 e-mails.
Sender address requirements (From Email)
Mailgun generally works with any sender address. However, for optimum deliverability, we recommend using an e-mail address linked to your domain name.
In a nutshell
Mailgun is one of the most reliable e-mail solutions on the market, and offers very competitive pricing. However, it requires access to your domain's DNS (Domain Name System) configuration.
Mailgun configuration with WPMasterToolKit
Create a Mailgun account
To begin configuration, you need a Mailgun account.
If you haven't already done so, the first step is to create your Mailgun account in order to continue setting up the SMTP service.

Note: Mailgun accounts created without a bank card are limited to sending e-mails to just 5 recipients.
Registration remains free, but you will need to add a credit card to your account if you wish to lift this restriction.
For further information, please consult Mailgun registration page.
Once you have completed the registration form, you will be asked to perform a few additional verification steps. These different levels of verification enable Mailgun to maintain a high level of e-mail deliverability for all its users.
First, you'll receive an e-mail to validate your Mailgun account. To start the verification process, click on the "Verify your email address.

After clicking this button, you will be asked to enter a cell phone number in order to receive a verification code by SMS.

Once you've completed these steps, you'll be automatically connected to your Mailgun account.
Add a domain
Once logged in, you should arrive at the Mailgun dashboard.
When you're ready, go to the left-hand menu and click on Sending " Domains.

On page Domainsclick on the "Add New Domain.

Note: If you don't see the button for adding a new domain, it probably means that you haven't entered your credit card details yet.
Mailgun requires all accounts (including free accounts) to add a credit card before they can continue.
Next, enter a subdomain of your main domain name. A sub-domain replaces the "www" part of your site address, for example : subdomain.example.com.
Sub-domains can be used to create separate sections of a site (such as some sites that use blog.example.com for their blog).
In this case, the subdomain will only be used by Mailgun to send e-mails and will not be visible on your site.
You can simply use a subdomain such as mail.example.com or mg.example.com. The exact name doesn't matter, but using mail or mg allows you to more clearly identify the use of this sub-domain.

In the Domain regionyou'll have to choose between two regions: US or EU.
If your site is hosted in the European Union, select EU.
If your site is hosted outside the European Union, leave the option US selected by default.
Then click on the "Advanced settings (DKIM) to access advanced options.
This setting adds an extra layer of security for spam protection.
We recommend selecting the 2048which generates a longer, more secure DKIM key.
To finish, click on the "Add Domain to continue.
For the rest of the tutorial, please keep this tab or window open, as we'll be coming back to this page a little later.
Checking your domain
To protect site owners and their visitors, some SMTP services (including Mailgun) require domain verification by adding records to your site's DNS.
You can find out more about the benefits of this verification in the Mailgun guide dedicated.
To get started, you need to access your domain's DNS settings.
If you don't know where to find them, Mailgun provides useful links directly on the configuration page when adding a new domain.
Once you've opened your domain's DNS settings, you should see an option to add a new record.
To allow Mailgun to check your domain, you will need to add two TXT records in your site's DNS.
Be sure to copy them accurately, as verification requires the correct exact values provided by your Mailgun account to work properly.
In Domain settings > DNS records click on Actions then on Turn on automatic sender security.

Note: If your DNS is managed by GoDaddy, you will need to slightly adapt the field Hostname indicated by Mailgun.
You will need to delete your main domain name when entering the Hostname in GoDaddy's DNS zone.For example, instead of entering
mg.yourdomain.comfor the Hostname of the first TXT record, simply entermg.
In your domain's DNS settings, you may also see a field called TTL (Time To Live) for each recording.
If you have the possibility of modifying it, we recommend that you set the TTL to one day (or 86400 secondsdepending on the unit used by your DNS manager).
Once the two recordings TXT you will have to proceed in the same way to add the recordings next present in Sending records.

Then add the Receiving records and Tracking records then click on Enable DMARC

Checking the status of your Mailgun domain
Mailgun should now check that your domain's DNS records are correctly configured.
This check may take some time (sometimes 24 to 48 hours), because DNS records are not propagated immediately.
You can check the validation status of your domain by clicking on the "Check status.

You should see the status Verified if everything is OK.

Configuring the SMTP module in WPMasterToolKit
MasterToolKit.
Before you start, make sure that WPMasterToolKit is properly installed and activated and that SMTP Mailer is active on your WordPress site.
See you in WPMasterToolKit " SMTP Mailer to access the SMTP module configuration page.
From Email
Visit From Email is the e-mail address from which all e-mails from your site will be sent. This address must use the same domain name as the one authorized in Brevo.
For example, if you have authorized the example.comaddress From Email must also contain this domain (for example : contact@example.com).
You can also check the "Force the usage of the sender name/email...".
If you want to use the same sender address for the whole site, this option will save you from having to change e-mail settings in different WordPress plugins or features.
By default, the From Name is the name of your site. You can, however, change the name and add any text you like.
You can also activate the "Force From Name to apply this sender name to all e-mails sent from your site.

Mailgun API key
Even if the verification of your domain is still pending, Mailgun has already made this information available to you. In fact, you may have automatically received an e-mail containing your Mailgun API key.
If not, return to the tab or window displaying the details of your Mailgun domain.
In the top right-hand corner of your Mailgun account, click on the small circle with your initials, then select the option "API Security.

You will then be redirected to a page displaying your Mailgun API keys.
Note: In your Mailgun account, you will usually see three API keys :
- Verification Public key
- HTTP Webhook Signing key
- Mailgun API keys
We recommend using the "Mailgun API key to configure emailing on your WordPress site with WPMasterToolKit.
The use of Verification Public key will lead to deliverability problems for e-mails to your site.
To generate your Mailgun API key, scroll down the page to section "Mailgun API keysthen click on the "Create API key.

A modal window will then open, allowing you to add a description for your API key.
We recommend that you provide a clear description so that you can easily remember how to use the key.
When ready, click on the "Create Key.

A new modal window will then appear with your new API key.
Make sure you copy it and keep it in a safe, accessible place, because this key is displayed only once.
You can copy it by clicking on the copy icon next to the key.

Note: If you lose your Mailgun API key, you'll need to generate a new one by repeating the previous steps in this section.
Once the complete key has been copied, return to the SMTP settings for WPMasterToolKit and paste it into the Mailgun API Key.

Note: If you have an old Mailgun account, your key may begin with the prefix key-.
Be sure to copy this prefix and include it in the SMTP settings for WPMasterToolKitFailure to do so could lead to verification problems.
Domain name
In the Domain Nameenter the sub-domain you have created in Mailgun (for example : mg.example.com).

Region
Finally, check the Region.
This must correspond to the region you have defined in Mailgun.
If your site is hosted outside the European Union, select the option US.

Note: Before continuing, please ensure that the domain verification process has been completed.
This may take some time, so you may need to revisit this step at a later date.
Configuration test
Once you've saved your settings, you can now run an email test to make sure everything's OK.
Go to the E-mail testthen enter an e-mail address to which you would like to send your test, then click on Send Now.

If you receive an error message, go back and check the previous steps.
If you get a confirmation message and receive the email, you've finished configuring.
Conclusion
Setting up Mailgun as an SMTP server on WordPress with WPMasterToolKit requires a little more rigor than a more "turnkey" SMTP solution, not least because of DNS settings and domain verification. In return, you benefit from excellent deliverability, great stability and a system that's perfectly suited to WordPress sites in production, including those that send a high volume of e-mails.
Once the configuration is complete and the send test validated, you'll have a sound, professional basis for all your site's e-mails: forms, notifications, WooCommerce, user accounts, etc. By centralizing this configuration via WPMasterToolKit's SMTP Mailer module, you also simplify maintenance and avoid scattered settings in different plugins.
If you're looking for a reliable, scalable and proven solution for sending transactional e-mails on WordPress, Mailgun remains an excellent choice today. You can now send your e-mails with complete peace of mind, with a robust configuration that complies with good deliverability practices.