Hi everyone! I’m Abhansh, and I’m working on Making Transactional Email Templates Dynamic project for GSoC 2018. If you want more information about what this project is all about, check out the gitlab here. Mails are the de-facto standard for e-communication these days. We will be using MJML as our templating engine.
Some other templating engines :
This project will help CiviCRM users to create individual mail templates which are responsive and look modern rather than the current set of choices they have which are basic HTML templates or plain text emails which don’t give the user many choices of customization.
This project will build an extension which will provide users with the integration for MJML. This will dramatically improve the look, feel and functionality of emails sent out to the end users of CiviCRM. The emails made with MJML provide a structure and markup similar to HTML and is easy to learn and use.
MJML, at the same time, provides all the emails as responsive emails which will make them look good on all the devices without any additional concerns to take care of. We have thought about and implemented many different ways of implementing MJML in our extension.
MJML templates need to be compiled to plain HTML before they can be sent out. This will require some kind of script or API which can take the MJML content given by the user as input and give plain HTML as output. MJML provides API for this purpose.
MJML has npm package which can compile the MJML locally which would be great in terms of speed since it is fast. For this, we would require a node server up and running everytime we need to do an API call to compile MJML to HTML. This would put significant load on the system it is running.
We then tried to figure out some other way to implement the same and finally settled on implementing a node script which can be executed on demand and can compile and return the HTML code when we provide it with a valid MJML string. This approach is super fast, saves time, efforts and computing power while providing an instant response to the user's changes.
We have also prepared MJML templates for the already present HTML templates in CiviCRM which would make them responsive and they will behave as a headstart for the users trying to create their own templates.
We have implemented the functionality to add, edit and delete templates on the admin panel of CiviCRM. This would allow admin to view the existing email templates as well as providing functionality to create new templates, edit existing templates and enable/disable those templates.
This project now aims at making this experience of sending emails better by integrating MJML templates in all the email forms. Currently, it works only with the new email creation form but soon it will be working in other places too(Schedule Reminders, etc). This would ultimately make the end user’s experience better with responsive emails.