Mailgun is a high-performance email service designed to send, receive, and track emails. Some things you might want to do with Mailgun include sending through it using Mailgun as an SMTP relay, which makes it relatively easy to send emails from any application or server in your infrastructure. In the following steps, you will learn how to set up Mailgun as an SMTP relay.
What is an SMTP Relay?
An SMTP relay is a way for your email server or application to get its email through another email server, in this case, Mailgun. By using Mailgun’s SMTP relay you get to utilize the power behind Mailgun’s robust infrastructure on top of sending emails that come directly from your own mail server but with a great degree of tracking and managing your emails.
How to Configure Mailgun as an SMTP Relay Step-by-Step
Step 1: Create a Mailgun Account
- Sign Up: if you haven’t signed up for an account using the Mailgun website.
- Verify your e-mail address to activate your account following sign-up.
Step 2: Add Your Domain
- Domains Management: In the Mailgun dashboard go to the “Domains” section.
- Add Domain: Click “Add Domain” and enter your domain name, for example, yourdomain.com.
- Verify Domain Ownership: Mailgun will provide you with DNS records (TXT, MX, and CNAME) that you have to add to your domain’s DNS settings to prove ownership. Then, following their guidance, you can verify the ownership.
Step 3: Obtain SMTP Credentials
- Access API Keys: Once verified, access the “API Keys” section in the Mailgun dashboard.
- Get SMTP Credentials: Write down your SMTP username and password. The SMTP username will be something like [email protected].
Step 4: Configure Your Application or Server
Now, you’ll need to configure your application or server to use Mailgun as its SMTP relay. You’ll usually need the following SMTP settings:
- SMTP Server: smtp.mailgun.org
- SMTP Port:
- Use 587 for TLS
- Use 465 for SSL
- Username: Your Mailgun SMTP username (e.g. [email protected])
- Password: Your Mailgun SMTP password
Step 5: Testing Your SMTP Relay Configuration
You can test your SMTP relay configuration either using telnet from the command line or by sending an application test email.
Telnet
- Optional. Open Command Line: Open your command prompt or terminal.
- Connect to Mailgun SMTP:
“bash”
telnet smtp.mailgun.org 587
- Send Test Email: Test out the SMTP protocol by sending a test email. You can even test it with your language of choice, be it Python, PHP, and countless other options at hand.
Step 6: Keep Track of Your E-mails
Once you have set up Mailgun to act as your SMTP relay, you will track the status of emails sent by referencing the Mailgun dashboard. Logs and delivery reports are just a few things you can access.
FAQs
Can Mailgun be used as an SMTP relay for high volume sending?
Yes, Mailgun is designed for sending in bulk. You can use its API or SMTP relay to send at scale.
What if delivery fails with Mailgun?
If you have delivery problems, check your Mailgun logs in the dashboard for such issues. Just make sure your domain is there and DNS settings are fine.
Is there a limit to the number of emails that can be sent through Mailgun?
Mailgun offers various pricing plans indicating how many emails are allocated to you to send out each month. See their pricing plans for limits.
What’s the best way to securely protect my SMTP credentials?
Only share your SMTP credentials confidentially; they should not be exposed anywhere in the public code repository. Use environment variables or configuration files to keep it secure.
Conclusion
Setup Mailgun is quite simple and lets you leverage the power of Mailgun’s email infrastructure. Read on for straightforward instructions on setting up Mailgun so that you may easily send emails out of your applications or servers. The rich capabilities of tracking and controlling delivery of emails make Mailgun a great choice for developers and businesses to help their email communications. You can start using Mailgun right now to get guaranteed, full-proof email delivery and insightful analytics.