Setting up Maingun with WordPress

Reliable email delivery is essential for any WordPress website.

Whether you are sending contact form notifications, transactional emails from an online shop, or membership confirmations, relying on the default PHP mail function is often unreliable. Emails may end up in spam or fail to deliver at all. This is where Mailgun comes in: a professional email delivery service that ensures your messages are delivered securely and consistently.

Process

This guide explains how to set up Mailgun with WordPress, from creating your account to updating DNS records and installing the right plugin.

Step 1: Create a Mailgun account

Begin by signing up for a Mailgun account at mailgun.com. Once registered, log in to the Mailgun dashboard and create a new domain that you will use for sending emails. It is generally best practice to create a subdomain for email purposes, for example mail.yourdomain.com or mg.yourdomain.com. This keeps your email traffic separate from your main domain.

Step 2: Add and verify your domain

After adding your chosen domain in Mailgun, you will be provided with several DNS records that need to be added at your domain registrar or DNS host. These typically include:

Log in to your DNS provider and add these records exactly as shown. Be aware that DNS changes can take several hours to propagate, though they are often live much sooner. Mailgun will indicate once the records have been detected and your domain is verified.

Step 3: Generate your SMTP credentials

Once the domain has been verified, Mailgun will generate SMTP credentials. These are a username and password combination that WordPress will use to send mail securely through Mailgun’s servers. Keep these details safe, as you will need them shortly.

Step 4: Install and configure a WordPress SMTP plugin

To connect WordPress with Mailgun, install a reliable SMTP plugin such as WP Mail SMTP or Mailgun's own plugin. These plugin replaces the default PHP mail function with either SMTP authentication or use the Mailgun API.

WP Mail SMTP

After installing and activating the WP Mail SMTP plugin, go to its settings screen. Choose “Other SMTP” (or “Mailgun SMTP” if using the Mailgun-specific option), and then enter the following details:

Save your settings and use the plugin’s built-in test feature to send a test email. If your DNS records are correct and your credentials are valid, the test email should arrive in your inbox.

Official Mailgun Plugin

After installing and activating the Mailgun WordPress plugin, you will find the settings under Settings → Mailgun.

In the plugin settings, you will need the following information:

The plugin allows you to send email via the Mailgun API, which is faster and more secure than SMTP. API mode is recommended, but SMTP mode is also available if you prefer.

Save your settings and then use the built-in test function to send a message. If everything is set up correctly, the email will arrive in your inbox.

Step 5: Test and monitor

Once configured, send test messages from your website’s forms or e-commerce checkout to confirm that everything is working as expected. Mailgun’s dashboard provides detailed logs of every email sent, including delivery status and any errors. This is extremely useful for troubleshooting.

Keep an eye on the dashboard in the first few days to ensure emails are being delivered and not rejected. You may also wish to set up Mailgun’s webhooks for bounce and complaint tracking, though this is not essential for basic use.


Setting up Mailgun with WordPress is a straightforward process, but it makes a dramatic difference to the reliability of your site’s emails. By verifying your domain with the correct DNS records, configuring SMTP credentials, and installing a suitable WordPress plugin, you can be confident that your messages will reach inboxes rather than spam folders.

A reliable email delivery service is no longer a luxury for WordPress sites — it is a necessity. With Mailgun in place, you can rest assured that your communications are being delivered securely and consistently.

Ready to elevate your WordPress site?

Whether you're launching a new site, strengthening security, or integrating WooCommerce, I can help transform your vision into a high-performing online presence.

Contact me to discuss your WordPress project

More WordPress posts

Using WordPress as a static site generator

Static site generators have gained significant traction amongst developers, designers, and businesses seeking faster, more secure websites. Unlike traditional dynamic sites, which rely on a database to deliver content on…

Continue reading

Moving a WordPress Website with ACF and Custom Post Types to Brightspot CMS

Migrating a website from WordPress to Brightspot CMS can seem daunting, particularly when the WordPress installation relies heavily on Advanced Custom Fields and Custom Post Types. Both ACF amd CPT…

Continue reading

Better WordPress Performance

A slow-loading website can be frustrating, not only for your visitors, but for you as a business owner. If your WordPress site is taking too long to load, you’re not…

Continue reading

What's going on between WordPress and WP Engine?

The disagreement between WordPress and WP Engine has sparked considerable debate within the WordPress community and could have important implications for users of the WordPress content management system (CMS). WP…

Continue reading