- Best Practices
How To Create a Successful Triggered Email Program
This post was written and contributed by Jon Wilkinson, Software Engineer at DigitalChalk.
If you’ve ever taken a course online you’ve used a Learning Management System (LMS). DigitalChalk is an industry leading, multi-tenant Learning Management System serving two types of customers: corporate customers who deliver training to employees, and e-commerce customers who sell their own courses online.
A typical DigitalChalk customer can create events that generate email notifications such as receipt emails, user creation emails, course registration emails, course completion emails, password change emails, and many others. DigitalChalk has thousands of customers who in turn have hundreds (or thousands) of students that all receive emails in response to these various events. In short, DigitalChalk sends a lot of emails on behalf of customers.
DigitalChalk is now integrated with Mailgun to deliver course event emails through a Mailgun account, so you’ll have all the great features that Mailgun provides. Mailing lists, marketing campaigns, analytics, and email address validation help e-commerce customers market and sell courses, while incoming mail routing, webhook integration, click tracking, and fast APIs help deliver and track corporate training. Additionally, you can now use your domain email address for your DigitalChalk email notifications instead of no-reply@digitalchalkmail.com.
DigitalChalk currently integrates with Mailgun using the JavaMail API over SMTP, with support for both SSL on port 465, and TLS on port 587. Connecting your two accounts simply means entering your Mailgun SMTP credentials and from-address into DigitalChalk:
We also utilize the Mailgun custom tagging feature for each outgoing email. For example, the x-mailgun-tag mail header might have a value of “USERCREATED” or “COURSECOMPLETED”. This indicates which event in DigitalChalk triggered the notification and gives you even more detail in Mailgun. Here’s how those tags might look on the Mailgun control panel:
DigitalChalk uses a dedicated notification server cluster to distribute outgoing mail. The server cluster handles the connection, protocol, and payload (html, plain text, and attachments) exchanged with Mailgun. In the unlikely event (i.e., network down) that we cannot hand off the mail to Mailgun, we make use of various retry strategies to ensure the mail is eventually delivered. One such retry strategy is the Cubed Retry Strategy. The time period between retries increases by the cube of the attempt count, with a maximum of 5 retries. The code simply calculates the next attempt time:
1public Date nextAttemptDate(Notification n) {23 if (n.getAttempts() >= this.maxAttempts) {4 return null;5 }67 if (n.getLastAttemptedDate() == null) {8 return new Date();9 } else {10 long delayMillis = (long) (Math.pow(n.getAttempts() + 1, 3) * 1000 * 60);11 return new Date(n.getLastAttemptedDate().getTime() + delayMillis);12 }13 14} 15
If DigitalChalk cannot hand off the email to Mailgun on the first attempt, we wait 8 minutes (2^3) and try again. Then we wait 27 minutes for the 3rd attempt, 64 minutes for the 4th attempt, and 125 minutes for the 5th attempt. This strategy creates a nice curve for balancing retry chattiness versus reliability.
Retry strategies greatly reduce the chances for failure, but doesn’t eliminate them. Let’s say our customer changes their Mailgun password. Ten minutes later they update it in the DigitalChalk (via the screenshot above). That leaves a ten minute window where any outgoing notifications will fail to connect to Mailgun. Luckily in this example, the cubed retry strategy will successfully connect on the 3rd attempt. However, if the customer waits 4 hours to update their password in DigitalChalk, the retry strategy will be exhausted and the notification will not be delivered. We haven’t lost the notification though, customers can see failures (and causes) within DigitalChalk:
At this point, the customer can simply click to retry the original notification, and the delivery process starts all over. We’ve avoided potential duplicate emails, increased reliability, and made failures easy to handle when they do occur.
We’re excited to be launching this new integration with Mailgun. DigitalChalk customers who use Mailgun will not only have a stronger online presence because of email branding, but will also benefit from additional Mailgun features such as mailing lists, marketing campaigns, personalization, analytics, address validation, and tracking. If you’re a DigitalChalk customer, we encourage you to signup for your Mailgun account and begin establishing your own email branding today.
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%.
Click here to read more about our integration with Mailgun.
Last updated on August 28, 2020
How To Create a Successful Triggered Email Program
Designing HTML Email Templates For Transactional Emails
How to Improve Holiday Supply Chain Communication with Email
How to Improve the Way WordPress Websites Send Email
Email’s Not Dead Season 3 Is Finally Here
How To Prepare Your Infrastructure For Black Friday
The Path To Email Engagement In 2021: Key Learnings
How To Use Parallel Programming
What is Transactional Email? The Basics
How we built a Lucene-inspired parser in Go
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.