• Email DIY

DigitalChalk Leverages Mailgun For Transactional Email Notifications

Mailgun Team
5 min read

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.

Mailgun Integration

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.

Nuts and Bolts

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) {
2
3 if (n.getAttempts() >= this.maxAttempts) {
4 return null;
5 }
6
7 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.

Summary

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.

sign up

It's easy to get started. And it's free.

What will you accomplish with 10,000 free emails and a 100 free validations every month?

Sign Up For Free

Click here to read more about our integration with Mailgun.

Last updated on August 24, 2019

  • Related posts
  • Recent posts
  • Top posts
View all

Always be in the know and grab free email resources!

No spam, ever. Only musings and writings from the Mailgun team.

Mailgun is committed to protecting your privacy. Please read ourPrivacy Policybefore providing us with your details.

sign up

It's easy to get started. And it's free.

What will you accomplish with 10,000 free emails and a 100 free validations every month?
Sign up for Free