How to Complete Your Mailgun SMTP Setup (A to Z Guide)
Mailgun SMTP Setup: The Definitive Guide for Developers & Businesses
As your application or website grows, a critical challenge emerges: how to send transactional emails at scale without them failing or landing in the spam folder. Your platform’s ability to reliably send password resets, welcome emails, and purchase receipts is not a luxury; it is a core function that directly impacts user trust and operational success. Relying on a basic server mail function at this stage is no longer a viable option.
Mailgun’s SMTP service is a powerful, developer-first solution designed specifically for high-volume, reliable email delivery. While its features are robust, a correct setup is absolutely essential to unlock its full potential and achieve the deliverability your business depends on.
This definitive guide is designed to walk you through every necessary step. We will cover every aspect of the Mailgun SMTP setup, from understanding the platform’s core concepts and authenticating your domain to finding your credentials and integrating them with your website.
Understanding Mailgun: More Than Just a Simple SMTP Server
Mailgun is a developer-focused email service provider that offers powerful APIs and a robust SMTP relay, designed primarily for sending scalable transactional and marketing emails from within applications and websites. Unlike some simpler services that are built primarily for manual newsletter creation in a visual editor, Mailgun’s foundation is built on providing a highly reliable and programmatic way to send email. It is an infrastructure tool, first and foremost.
It is engineered to solve the complex problems of email deliverability at scale. This includes managing IP reputations, providing detailed analytics on email performance, and giving users granular control over their sending configurations. Mailgun treats email not just as a message, but as a form of data that can be sent, tracked, and analyzed with precision.
This technical focus makes it a favorite among software developers and businesses that have outgrown the limitations of more basic email marketing platforms. They choose Mailgun when they need to be certain that their application’s critical emails are being delivered and when they need deep, actionable insights into what happens to those emails after they are sent. It is less of a simple “email sender” and more of a complete email delivery engine.
The Difference Between Mailgun’s API and SMTP Relay
A crucial concept to grasp when working with Mailgun is the difference between its two primary sending methods: the API and the SMTP Relay. While both achieve the end goal of sending an email, they represent two different philosophies of integration.
The SMTP Relay is built on the universal standard for sending email. This is the method we are focusing on for a traditional Mailgun SMTP setup. It allows any existing application, plugin, or piece of software that supports standard SMTP credentials to send email through Mailgun without requiring any custom coding. An administrator can simply take the SMTP credentials—a server name, username, and password—and plug them into their application’s settings. This makes it the perfect solution for integrating with off-the-shelf software like WordPress, Magento, or other content management systems.
The API (Application Programming Interface), on the other hand, is Mailgun’s true power center and is designed for developers. Instead of using a standard protocol, a developer writes code that communicates directly with Mailgun’s systems. This method is faster, more flexible, and provides more control. It allows for sending more complex emails, managing lists programmatically, and receiving detailed feedback through webhooks. A developer would choose the API when building a custom application from scratch, as it offers superior performance and capabilities. For most business users looking to connect an existing website, the simpler SMTP integration is the correct path.
Why Mailgun is a Preferred Choice for Technical Users
Mailgun has earned its reputation as a preferred choice for technical users and developers because it provides an unparalleled level of control and transparency over the entire email sending process. While other services might focus on pretty email templates, Mailgun focuses on the raw data and mechanics of deliverability.
One of its standout features is its detailed logging and analytics. The Mailgun control panel provides real-time logs of every single email event. You can see precisely when an email was accepted by the server, when it was delivered to the recipient’s inbox provider, when it was opened, and when a link was clicked. If an email fails to deliver (a “bounce”), Mailgun provides a detailed diagnostic reason, which is invaluable for developers trying to troubleshoot delivery issues. This granular insight removes the guesswork from email deliverability.
Furthermore, Mailgun offers advanced deliverability tools that are essential for high-volume senders. This includes features like dedicated IP addresses, which allow a business to build its own sending reputation completely isolated from other users. It also provides suppression lists, tracking for unsubscribes, and detailed reporting on your domain’s health. For a developer or a technical marketer, this data-rich environment is a powerful toolkit for optimizing email performance and ensuring that critical messages are not just sent, but are successfully delivered and engaged with. This focus on providing actionable data is a key reason why many choose to complete a full mailgun smtp setup.
How to Find Your Correct Mailgun SMTP Settings
Your specific Mailgun SMTP settings are generated for each sending domain you add to your account and can be found in the ‘Domain settings’ section of the Mailgun control panel. Unlike some other services that use one universal set of credentials for all users, Mailgun’s approach is more secure and more organized. It ties each set of sending credentials directly to a specific domain that you have verified within your account.
This means that before you can even find your SMTP credentials, you must first tell Mailgun which domain you intend to send email from. This domain-centric approach is a core part of the platform’s philosophy, as it helps maintain a clean sending reputation and makes it easier to manage multiple projects or websites from a single account.
You cannot simply sign up for Mailgun and immediately find a generic set of credentials to use. The process requires you to first register your sending domain, after which Mailgun will provide a unique SMTP username and password specifically for that domain. This ensures that every email sent through the system is associated with a verified domain, which is the first step in building a trusted sending infrastructure.
A Guide to the Mailgun Control Panel
The Mailgun control panel, or dashboard, is your central hub for managing your email sending operations. Navigating it for the first time is key to understanding how to access your credentials. The entire process hinges on the concept of “Sending Domains.”
Upon logging in, your first major task is to add the domain you will be using to send emails. This is typically done in a prominent section of the dashboard labeled Sending or Sending Domains. Here, you will add your domain name, such as mybusiness.com.
Once you have added a domain, it will exist in an unverified state. Before you can send emails from it, you must complete the domain authentication process, which we will cover in the next section. It is only after your domain is fully verified that Mailgun will provide you with the necessary SMTP credentials to use.
After verification, you can navigate back to your list of Sending Domains. Clicking on your verified domain name will take you to a detailed overview page for that specific domain. It is on this page, often under a tab or section named Domain Settings or SMTP credentials, that Mailgun displays the precise information you need for your mailgun smtp setup. This is where you will find your unique username and where you can create a secure password for that username.
Your Mailgun SMTP Credentials Explained
Once you have located the correct section within your verified domain’s settings, Mailgun will provide you with all the necessary information. It is crucial to copy these details exactly as they appear.
Here is a clear explanation of the specific mailgun smtp credentials you will need:
- Hostname / Server:
smtp.mailgun.org(for US region) orsmtp.eu.mailgun.org(for EU region)This is the address of the Mailgun sending server. Unlike some other settings, this can vary. When you set up your Mailgun account, you choose a data storage region (US or European Union). The SMTP hostname you use must correspond to the region you selected. Using the wrong one will result in a connection failure. - Port:
587This is the recommended and most common port for sending email. It uses an opportunistic encryption method called STARTTLS, which ensures your connection to the Mailgun server is secure. - Username: Your full SMTP UsernameThis is one of the most important details. Your username will be a long, unique email address generated by Mailgun specifically for your sending domain. It will look something like
postmaster@mg.mybusiness.com. You must use this full, specific username. You cannot use your main account email address. - Password: Your Unique SMTP PasswordIn the same section where you find your username, Mailgun provides a button to Reset password or Manage SMTP credentials. Here, you can generate a new, strong password specifically for this SMTP user. It is this unique password, not your main account password, that you must use for your SMTP connection.
Mailgun Domain Authentication: The Most Critical Setup Step
Properly authenticating your domain with Mailgun is the most critical step for achieving high deliverability, as it requires adding several DNS records (SPF, DKIM, and sometimes MX) to prove ownership and build a trusted sending reputation. If you attempt to send emails from an unauthenticated domain, they will be heavily throttled, will display a “via mailgun.org” message, and are almost guaranteed to land in the spam folder. Authentication is not an optional step; it is a mandatory requirement for any serious sender.
This process serves as the foundation of your entire email program. It is the official, public declaration that you, the owner of your domain, have authorized Mailgun to send emails on your behalf. This verification is what separates your legitimate emails from a spammer who might be trying to forge your email address.
Inbox providers like Gmail and Microsoft are constantly fighting a war against spam and phishing, and unauthenticated email is their number one enemy. By completing Mailgun’s authentication process, you are giving these providers exactly what they are looking for: verifiable proof of your identity. This immediately elevates the level of trust they place in your messages, which is the key to achieving high inbox placement rates.
Why Mailgun’s Authentication is So Thorough
When you begin the domain authentication process in Mailgun, you may notice that it is more detailed than some other services. This is by design. Mailgun is an infrastructure platform built for professional senders, and its authentication process is engineered to establish a very strong and resilient sending reputation from the very beginning. It does this by requiring you to set up several types of DNS records.
The first is an SPF (Sender Policy Framework) record. As we’ve discussed before, this is your public guest list that tells the world Mailgun is an approved sender for your domain.
The second is a DKIM (DomainKeys Identified Mail) record. This provides a tamper-proof digital signature on every email, proving it is authentic and has not been altered.
Uniquely, Mailgun also requires you to add MX (Mail eXchange) records for a special subdomain. While MX records are typically used to receive email, Mailgun uses them in this context to handle incoming bounce reports and other feedback, giving it a more robust system for tracking email delivery and problems. By requiring this comprehensive set of records, Mailgun ensures your domain is configured for maximum deliverability and a professional sending reputation right from the start, making the full mailgun smtp setup more effective.
A Step-by-Step Guide to Authenticating Your Sending Domain
The authentication process involves a simple but precise exchange of information between your Mailgun account and your domain registrar (where you purchased your domain name).
Conceptually, the process works like this:
- You begin inside your Mailgun control panel, in the Sending Domains section. Here, you will add the domain name you wish to send from.
- Once the domain is added, Mailgun’s system will automatically generate a unique set of DNS records specifically for that domain. It will typically show you two TXT records (for SPF and DKIM) and two MX records. Each record will have a “Hostname” and a “Value.”
- Your task is to take this information and enter it into your domain’s DNS management panel. You will open a new browser tab and log in to your domain registrar (like GoDaddy, Namecheap, etc.).
- In your DNS settings, you will create new records that exactly match the information Mailgun provided. For each record, you will carefully copy the “Hostname” from Mailgun and paste it into the “Host” or “Name” field at your registrar. You will then copy the “Value” from Mailgun and paste it into the “Value” or “Points to” field. You must do this for all the records Mailgun generated.
- After you have added all the records and saved your changes, you must wait for these updates to become visible on the internet, a process called propagation which can take anywhere from a few minutes to several hours.
- Finally, you return to the Mailgun dashboard and click a Verify DNS Settings button. Mailgun’s system will then scan your domain’s public records. If it finds the records you just added, your domain will be marked as “Verified,” completing this crucial step.
Integrating Mailgun SMTP with Your WordPress Site
For a WordPress site, the most reliable way to complete your Mailgun SMTP setup is to use an SMTP plugin like WP Mail SMTP, which securely stores your credentials and reroutes all website mail through the Mailgun relay. The default way that WordPress sends email is notoriously unreliable. It uses a basic server function that lacks the proper authentication required by modern inboxes, which is why so many important notifications from contact forms and e-commerce plugins end up being flagged as spam.
An SMTP plugin is a non-negotiable tool for any serious WordPress site owner as it completely solves this problem. It works by intercepting every email your website attempts to send. Instead of allowing WordPress to use its flawed default method, the plugin establishes a secure, authenticated connection to your professional Mailgun account.
It then passes the email to Mailgun’s powerful delivery engine to be sent. This process ensures every message your site generates—from password resets to new comment notifications—is sent with the high deliverability and strong reputation of your authenticated Mailgun account. Using a plugin is a far safer and more stable solution than attempting to hard-code your sensitive credentials into your website’s files.
Using the “Other SMTP” Mailer for Mailgun
While some SMTP plugins have a dedicated, one-click integration for Mailgun, many of the most popular free options, including the standard version of WP Mail SMTP, require you to use their generic “Other SMTP” option. This is a perfectly effective method that simply means you will be manually entering all of your credentials instead of having some of them pre-filled.
The process starts in your WordPress dashboard, where you will navigate to the plugin repository to install your chosen SMTP plugin. Once the plugin is installed and activated, you will proceed to its setup or settings page. Here, you will be presented with a list of different “mailers” or email service providers.
Your task is to select the “Other SMTP” mailer. Choosing this option will then display a form with a set of blank fields for the hostname, port, encryption, username, and password. This form is the universal standard for any SMTP connection. It provides the plugin with all the necessary information it needs to connect to any provider, including Mailgun. This manual approach offers complete control and is a reliable way to configure Mailgun SMTP on your site.
How to Enter Your Mailgun Credentials and Verify the Connection
This is the final step where you connect all the dots. On the “Other SMTP” settings screen within your plugin, you will carefully enter the specific mailgun smtp settings that you previously retrieved from your Mailgun control panel.
First, you will input the Hostname, which will be smtp.mailgun.org or smtp.eu.mailgun.org, depending on your account’s region. Next, you will set the Encryption to TLS and the Port to 587. These settings must be exact.
Below this, you will enable authentication and fill in the username and password. For the Username, you must paste the full SMTP username provided by Mailgun, such as postmaster@mg.mybusiness.com. For the Password, you must paste the unique, long password that you generated for that specific SMTP credential inside your Mailgun domain settings.
After you have filled in all these fields and saved your settings, you must verify the connection. All good SMTP plugins have a built-in “Email Test” tab. Navigate to this tab, enter an email address you can check, and send a test. The plugin should report an on-screen success message, and you should receive the test email in your inbox moments later. This successful test is your final confirmation that your mailgun smtp setup is complete and working correctly.
Concluding Summary
Successfully completing your Mailgun SMTP setup is a powerful step towards professionalizing your website’s email delivery. By moving away from unreliable default server mail and leveraging Mailgun’s robust infrastructure, you ensure your critical transactional emails are sent with the trust and authority that modern inboxes demand. While the process is detailed, particularly the domain authentication stage, it is a one-time investment in the reliability and reputation of your brand. You are now equipped with a best-in-class email delivery engine, giving you the confidence that your messages are not just being sent, but are being delivered.





