Mailgun SMTP Settings (2026)
Complete guide to configure Sinch Mailgun SMTP relay for transactional emails. Includes domain verification, US/EU regions, SMTP credentials, and code examples.
table_chart Mailgun SMTP Quick Reference
| SMTP Server (US) | smtp.mailgun.org |
| SMTP Server (EU) | smtp.eu.mailgun.org |
| Port (STARTTLS) |
587
check_circle
Recommended
|
| Port (SSL/TLS) | 465 |
| Alternative Port |
2525
(if 587 blocked)
|
| Username | postmaster@yourdomain.com |
| Password | SMTP Password from domain settings |
| Encryption | TLS 1.2+ required |
US vs EU Region
Mailgun has separate US and EU data centers. Your domain is registered in one region only. EU region uses smtp.eu.mailgun.org and is GDPR compliant.
checklist Prerequisites
- check_circle Mailgun account - Sign up free
- check_circle Verified domain with DNS records configured
- check_circle SMTP credentials created for your domain
- info Credit card required to remove sandbox restrictions
integration_instructions Step-by-Step Setup
Add Your Domain
- 1. Go to Sending → Domains
- 2. Click "Add New Domain"
-
3.
Enter your domain (recommended: use a subdomain like
mg.yourdomain.com) - 4. Select region: US or EU (cannot be changed later)
lightbulb Pro Tip: Use a subdomain (mg.domain.com) instead of your root domain. This separates marketing email reputation from your main domain.
Configure DNS Records
Add these DNS records to verify your domain:
Required DNS Records
| Type | Host | Value | Purpose |
|---|---|---|---|
| TXT | mg.yourdomain.com | v=spf1 include:mailgun.org ~all | SPF |
| TXT | k1._domainkey.mg.yourdomain.com | k=rsa; p=MIGfMA0... | DKIM |
| CNAME | email.mg.yourdomain.com | mailgun.org | Tracking |
| MX | mg.yourdomain.com | mxa.mailgun.org (priority 10) | Receiving |
* Actual values will be provided by Mailgun during setup
Create SMTP Credentials
- 1. Go to your domain's settings page
- 2. Navigate to "SMTP Credentials" tab
-
3.
The default
postmaster@mg.yourdomain.comcredential is already created - 4. Click "Reset Password" to generate a new password (or create a new credential)
warning Important: Save your SMTP password immediately! Mailgun will only show it once. If you lose it, you'll need to reset it.
Configure Your SMTP Client
Use these settings based on your region:
US US Region
smtp.mailgun.org587EU EU Region (GDPR)
smtp.eu.mailgun.org587postmaster@mg.yourdomain.com
[your SMTP password]
code Code Examples
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import os
# Mailgun SMTP Configuration
# Use smtp.eu.mailgun.org for EU region
SMTP_SERVER = 'smtp.mailgun.org'
SMTP_PORT = 587
SMTP_USERNAME = os.environ.get('MAILGUN_SMTP_USER') # postmaster@mg.yourdomain.com
SMTP_PASSWORD = os.environ.get('MAILGUN_SMTP_PASSWORD')
def send_email(to_email, subject, body):
msg = MIMEMultipart('alternative')
msg['From'] = 'sender@mg.yourdomain.com'
msg['To'] = to_email
msg['Subject'] = subject
# Optional: Add custom headers for tracking
msg['X-Mailgun-Tag'] = 'welcome-email'
msg['X-Mailgun-Track-Opens'] = 'yes'
msg['X-Mailgun-Track-Clicks'] = 'yes'
html_part = MIMEText(body, 'html')
msg.attach(html_part)
with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server:
server.starttls()
server.login(SMTP_USERNAME, SMTP_PASSWORD)
server.send_message(msg)
print('Email sent successfully!')
# Usage
send_email(
'recipient@example.com',
'Hello from Mailgun',
'<h1>Welcome!</h1><p>This is a test email.</p>'
)
star Mailgun SMTP Features
Mailgun supports custom SMTP headers for advanced functionality:
| Header | Values | Description |
|---|---|---|
X-Mailgun-Tag |
any string | Tag for analytics grouping |
X-Mailgun-Track |
yes / no | Enable/disable all tracking |
X-Mailgun-Track-Opens |
yes / no | Track email opens |
X-Mailgun-Track-Clicks |
htmlonly / yes / no | Track link clicks |
X-Mailgun-Deliver-By |
RFC 2822 date | Schedule delivery |
X-Mailgun-Require-TLS |
true / false | Require TLS for delivery |
webhook Webhooks
Real-time event notifications for opens, clicks, bounces, and complaints.
inbox Inbound Routing
Receive emails at your domain and route to your application via webhook.
payments Mailgun Pricing (2026)
| Plan | Emails/Month | Price | Features |
|---|---|---|---|
| Flex (Trial) | 100/day | $0 | Sandbox domain, basic analytics |
| Foundation | 50,000 | $35/mo | Custom domain, 24/7 support |
| Scale | 100,000 | $90/mo | Dedicated IP, email validation |
| Enterprise | Custom | Contact sales | SLA, SSO, custom retention |
Prices as of January 2026. Check mailgun.com/pricing for current rates.
build Troubleshooting Common Errors
help Frequently Asked Questions
What is the Mailgun SMTP server address?
For US region: smtp.mailgun.org. For EU region: smtp.eu.mailgun.org. Use port 587 for TLS (recommended), port 465 for SSL, or port 2525 as an alternative.
What credentials do I use for Mailgun SMTP?
Mailgun uses domain-specific SMTP credentials. The default username is postmaster@yourdomain.com. You can also create custom SMTP credentials in your domain settings.
How many emails can I send with Mailgun free tier?
Mailgun's Flex tier includes 100 free emails per day forever (limited to sandbox domain). The Foundation plan starts at $35/month for 50,000 emails with full features.
What is the difference between US and EU Mailgun regions?
EU region stores data in European data centers for GDPR compliance. Use smtp.eu.mailgun.org for EU region and smtp.mailgun.org for US region. Your domain must be registered in the correct region.
Can I use my API key for SMTP authentication?
No, Mailgun SMTP requires separate SMTP credentials, not your API key. Create SMTP credentials in Domain Settings > SMTP Credentials. The API key is only for REST API calls.
Need Better Email Deliverability?
Postigo manages SMTP rotation, warmup, and deliverability optimization automatically across multiple providers.