How I built my own MailChimp app with AWS SES and MJML ✉️

Have you ever had to send repetitive emails in a job that you wished you could just automate?

Nicholas Vincent-Hill
HackerNoon.com
Published in
3 min readJun 5, 2019

--

What is dotmail.tech?

This is an open-source FERN-stack app to programatically send responsively-designed emails with Nodemailer and MJML templates (check out the code here).

Here’s an example email sent with my app:

An example templated email sent with dotmail.tech

Tech stack

Here’s the tech I used:

Front End

  • React.js — The front-end MVC framework
  • Redux — The state management
  • Jest — The testing framework
  • Enzyme — The testing utilities

Back End

  • Firebase — The OAuth and cloud Firestore database
  • Express — The server
  • Node.js — The back-end
  • Mustache — The logic-less template system
  • MJML — The framework that makes responsive email easy
  • SuperTest — The http integration testing

Deployed With

  • Docker — The package/container management
  • AWS SES — The flexible and highly-scalable email sending and receiving platform
  • AWS EC2 — The secure and resizable compute capacity in the cloud

Technical Challenges

There were a number of technical challenges I had to address to build this application.

In order to create a rich, responsive HTML email I used MJML and transpiled it to responsive HTML. This allowed me to write modular blocks of markup and not worry about 700+ lines of HTML and CSS required for each template to ensure a responsive experience for the end recipient.

I used Mustache to inject variables into the transpiled HTML to personalize content to each recipient. AWS SES has its own templating service but this free open-source tool worked well for me and has a simple-to-learn API.

AWS SES was the clear choice for the email sending service. My required throughput was well below the 60,000 free emails sent per month and AWS SES can churn through batches of emails to be sent (at least at my small scale) instantaneously.

I use Mail Tester to evaluate my emails to ensure they evade spam filters. This is a crucial step and taught me a lot about Apache SpamAssassin and how modern filters classify emails as spam or not. Metrics like raw text to HTML percentage and image to text ratio are important and can negatively affect how your email is classified to automated filters.

Future features

There are a number a features I’d still like to add to this project. The last major feature completed was a preview feature to view the email before sending built with React portals; the client can assemble the email and view a real-time preview in a different tab.

I also like to eventually add the ability to programmatically generate email from injected variables and pre-built “lego” building blocks of MJML. This could facilitate a newsletter or other recurring publication with a standard layout but variable content blocks.

Conclusion

I’m excited to use this application in my personal and professional life to automate away email stress. Repetitive emails at work, thank you notes, and birthday e-cards can and should be written once and programmatically generated with the required data injected.

I’d love to hear your comments/suggestions/critiques in the comments or make a pull request if you find anything that could be improved!

Read Next:

How to build and deploy a beautiful static site with AWS S3, Route53, and CloudFront

--

--

HackerNoon.com
HackerNoon.com

Published in HackerNoon.com

Elijah McClain, George Floyd, Eric Garner, Breonna Taylor, Ahmaud Arbery, Michael Brown, Oscar Grant, Atatiana Jefferson, Tamir Rice, Bettie Jones, Botham Jean