Mailgun SMTP Configuration

Use these exact values when configuring any email client or application to send through Mailgun servers.

Parameter Value
SMTP Host smtp.mailgun.org
SMTP Port 587 (TLS) or 465 (SSL)
Encryption STARTTLS on port 587, SSL on port 465
Username Default SMTP credentials from your Mailgun dashboard (postmaster@yourdomain)
Password Your SMTP password from the Mailgun dashboard

Note: Mailgun SMTP credentials are domain-specific. Each sending domain has its own credentials. Find your SMTP login details in the Mailgun dashboard under Sending > Domains > Domain Settings > SMTP Credentials.

Step-by-Step Setup

Follow these steps in order to configure SMTP access for Mailgun.

1. Add and Verify Your Domain

In your Mailgun dashboard, add your sending domain and complete DNS verification. This includes adding MX, SPF, DKIM, and tracking CNAME records to your domain's DNS.

2. Get SMTP Credentials

Navigate to your domain's settings in Mailgun to find your SMTP credentials. You can use the default "postmaster@yourdomain" or create a new SMTP user with a custom login.

3. Configure Your Application

Enter smtp.mailgun.org as the SMTP host, port 587 with TLS, your full SMTP username, and your SMTP password from the Mailgun dashboard.

4. Send a Test Message

Send an email to yourself and an external address to confirm delivery. Check the Mailgun dashboard for delivery logs and any issues reported.

Common Errors and Solutions

Most Mailgun SMTP issues fall into a handful of categories. Here's how to fix them quickly.

Domain Not Verified

Mailgun requires domain verification before sending. Check your DNS records are correctly configured. Use the Mailgun DNS verification tool to confirm all records (MX, SPF, DKIM, CNAME) are properly set.

Wrong Credentials

SMTP credentials are domain-specific in Mailgun. Make sure you're using credentials from the correct domain. Each sending domain has its own separate SMTP username and password.

Connection Timeout

Port 587 may be blocked by your network. Try port 465 with SSL encryption as an alternative. Corporate firewalls commonly block direct SMTP on port 587.

Sending Limits Reached

Mailgun has monthly sending limits based on your plan. Free accounts can send up to 5,000 emails/month. Exceeding limits results in temporary sending suspension until the next billing cycle.

Best Practices for Mailgun SMTP

Keep your account secure and your messages deliverable with these recommended approaches.

Use Dedicated SMTP Users

Create separate SMTP credentials for each application rather than sharing the postmaster account. This allows granular revocation if a specific application's credentials are compromised.

Complete Full Domain Verification

Complete all DNS verification steps including MX, SPF, DKIM, and tracking CNAMEs. Full verification improves deliverability and allows Mailgun to track opens, clicks, and bounces.

Enable Webhook Notifications

Configure webhooks to receive bounce, complaint, and delivery event notifications. This allows your system to maintain a clean list by removing invalid addresses promptly.

Monitor Your Reputation

Track your domain's sending reputation in the Mailgun dashboard. High bounce rates and spam complaints can lead to throttling or suspension of your sending privileges.

When Mailgun SMTP Needs an Alternative

Mailgun is a solid email service provider, but its SMTP offering can become costly at high volume and lacks advanced routing features. If you're hitting Mailgun's rate limits or paying per-email fees that add up at scale, a dedicated SMTP relay service with predictable pricing may be more cost-effective.

For teams needing deeper analytics, custom DKIM signing across multiple domains, and intelligent routing rules, an email API platform provides more control. Learn more about email deliverability and how to protect your sender reputation at scale.

Frequently Asked Questions

What are Mailgun's SMTP sending limits?

Mailgun's limits depend on your plan. Free accounts can send up to 5,000 emails per month with 300 emails per day. Paid plans start at 50,000 emails per month and scale to millions for enterprise accounts.

Can I use Mailgun with a custom domain?

Yes. Mailgun is specifically designed for custom domain sending. Add your domain, complete DNS verification, and you can send from any address within that verified domain.

My Mailgun SMTP is being rejected. What should I do?

Verify your domain is fully verified with correct DNS records. Check you're using the correct SMTP credentials from the right domain. Try switching from port 587 to port 465. Verify you haven't exceeded your sending limits.

Is Mailgun suitable for transactional emails?

Yes, Mailgun is well-suited for transactional email. It offers webhook event notifications, detailed logs, and good deliverability when properly authenticated. However, costs can scale with volume.

How do I create additional SMTP users in Mailgun?

Navigate to your domain in Mailgun and go to Sending > Domain Settings > SMTP Credentials. You can create new SMTP users with custom usernames and passwords for different applications.

Ready to move to reliable email infrastructure?

Start free with no card, or talk to sales for high-volume and enterprise.

Start SendingTalk to Sales