An example of putting together MJML, Handlebars & Twillio Sendgrid for building responsive mails
- Clone the repository
- Run
npm install
- Add your Sendgrid API Key in
.env
file (refer to.env.default
file for ) - Add your Recipent Email
.env
file (refer to.env.default
file) - Run
node example.js
- The app loads
.env
environment configuration. - The view in
views/example.hbs
is loaded. - The loaded view (now as a string) is converted to an Handlebars Template.
- Then the template replaces the variables with the values in the
userInfo
object. - The Handlebar Template is converted to HTML.
- The HTML is passed to Sendgrid to generate the email.
Variable | Description |
---|---|
SENDGRID_API_KEY | API Key from Twillio Sendgrid. You can get one here |
RECIPENT_EMAIL | Recipent user email |
FROM_EMAIL | Email used for sending email |
FROM_EMAIL_NAME | Name used for sending email |
FROM_EMAIL_SUBJECT | Subject in the email |