Templated transactional emails in MJML

A microservice for developing, testing and sending templated transactional emails in your next app

Remove boilerplate SMTP code, take advantage of templates in any language, and fix email client issues with MJML.

The Status Quo

As a developer, having worked on many applications I think I’ve written a “forgotten your password” email a thousand times. The same goes for “Welcome to product X” or “Purchase confirmation”.

These transactional emails are a simple necessity in almost all apps and thankfully they’re not that complex. You just have to write some HTML. And it’s dynamic, so setup a template language, like Twig, Handlebars, or Jinja2.

For good measure, add a plain-text version for old email clients and spam filters.

Now send it, just integrate a library like SwiftMailer, or Nodemailer, configure your SMTP or API details within your framework of choice.

Oh, but this email needs a PDF attachment, and of course that’s dynamically generated too, and you probably need to see quite a few versions of the email and PDF before you’re done, so maybe build a way to test what they look like in development.

Speaking of development, you’re not actually sending these email are you? No, you’re probably using Mailhog, or Mailcatcher.

Reinventing the wheel

So it’s simple. No really, most of us developers have done this many times and not had much trouble. But it’s a lot of work. All this time spent configuring libraries, tools and services, when there’s so many more interesting things to build.

All of these libraries and tools have improved this considerably, but in the new era of microservices and 12factor apps, I think we can do better.

Enveloper is a simple API-driven service which you can run through a public docker image, mount your templates, configure credentials for your favourite mail delivery service, and you’re ready.

Now a simple API request will:

  • Parse and resolve placeholders using a template language like Twig

Additionally, it:

  • Handles plain text versions

Head over to Github to get started, or to Twitter to follow along for updates on new features; there’s plenty on the way! Have an idea or a question? Missing something? I’m happy to help.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store