- Events
Meet Our Amazing Pathwire Mavericks!
This post was written and contributed by Major Hayden, Principal Architect at Rackspace.
Today’s multi-cloud world allows for lots of flexibility, but infrastructure sprawl creates serious challenges for email delivery. Mailgun customers already know how it can help them send critical business emails, such as receipts, newsletters, and promotions. What about all of those other emails that servers need to send when something goes wrong?
Servers often need to send out an alert via email when something goes wrong or when an administrator needs to be aware of a change. For example, most cron job failures end up creating emails that are shipped to someone on the system. These emails often fall into the root
user’s mailbox.
For some servers, root
‘s mailbox is a black hole because the account isn’t configured to forward email elsewhere. For others, a system administrator might configure another address to receive the root
user’s email. Getting that email delivered outside the server is challenging in cloud environments for many reasons:
Many IP addresses on cloud platforms are already in email blocklists
Reverse DNS isn't always configured correctly by administrators in cloud environments
Maintaining SPF records for constantly fluctuating environments is difficult
Distributing DomainKeys configurations reliably is also difficult
Some alert emails may be dropped into spam folders due to their content, despite getting everything right in the mail server configuration
Some cloud providers block outbound connections on common SMTP ports (like 25, 465, and 587)
Mailgun can deliver these important emails reliably on almost every system with internet access. Common MTA’s like postfix or sendmail can connect to Mailgun’s SMTP Relay service and send email with very little configuration. In addition, all of that email can be delivered securely with SSL/TLS.
I’ve made this process a little easier by creating an Ansible role called ansible-mailgun that will install postfix and configure it to use Mailgun as an SMTP relay. The role can be easily added to any existing Ansible playbook:
1- name: Deploy Mailgun SMTP configuration2 hosts: all3 vars:4 - mailgun_username: (mailgun_smtp_username)5 - mailgun_password: (mailgun_smtp_password)6 - root_forward: name@example.com7 roles:8 - ansible-mailgun
There are only three variables to configure for the role to work. First, the mailgunusername and mailgunpassword appear in the Mailgun dashboard for each domain under the Domain Information heading. The rootforward_ variable should be set to an email address that can receive the email for the root
user on each server.
Here’s how it works when an alert email is generated on one of the servers with the ansible_mailgun
role applied:
The alert email is dropped into the postfix’s delivery queue for root
Postfix connects to Mailgun via SMTP to forward the email (the address configured as root
forward_ in
the Ansible role)
Mailgun delivers the email to the user who is configured to receive root
‘s email
This mail delivery path ensures that your alerts are delivered reliably, no matter where they’re generated.
Learn about our Deliverability Services
Looking to send a high volume of emails? Our email experts can supercharge your email performance. See how we've helped companies like Lyft, Shopify, Github increase their email delivery rates to an average of 97%.
Last updated on February 22, 2022
Meet Our Amazing Pathwire Mavericks!
International Women’s Day: How Pathwire’s Female Leaders Choose To Challenge
Mailpets: For The Love Of Animals
The Mailgun Maverick Program Is Here!
Force for Change: It's Time to Speak Out
HTTP Crash Course
Sending Email Using The Mailgun PHP API
Building Email Lists Of Contacts That (Actually) Want To Hear From You
Mailgun For Non-Devs: Leveraging An Email Marketing Platform
A Practical Guide To Using Mailgun’s Webhooks
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Become an Email Pro With Our Templates API
Google Postmaster Tools: Understanding Sender Reputation
Navigating Your Career as a Woman in Tech
Implementing Dmarc – A Step-by-Step Guide
Email Bounces: What To Do About Them
Announcing InboxReady: The deliverability suite you need to hit the inbox
Black History Month in Tech: 7 Visionaries Who Shaped The Future
How To Create a Successful Triggered Email Program
Designing HTML Email Templates For Transactional Emails
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Implementing Dmarc – A Step-by-Step Guide
Announcing InboxReady: The deliverability suite you need to hit the inbox
Designing HTML Email Templates For Transactional Emails
Email Security Best Practices: How To Keep Your Email Program Safe
Mailgun’s Active Defense Against Log4j
Email Blasts: The Dos And Many Don’ts Of Mass Email Sending
Email's Best of 2021
5 Ideas For Better Developer-Designer Collaboration
Mailgun Joins Sinch: The Future of Customer Communications Is Here
Always be in the know and grab free email resources!
By sending this form, I agree that Mailgun may contact me and process my data in accordance with its Privacy Policy.