Mailik
Mailik is a ecosystem for send mail in your app :
- Send mail with nodemailer
- Template HTML with mjml
- html, text and subject is a template with handlebars
Exemple
Prepare templates :
Html version :
invoice.mjml
<mjml> <mj-body> <mj-section> <mj-column> <mj-text><h1>Hello {{name}}</h1></mj-text> <p>You'r Invoice :</p> <mj-table> {{#each products}} <tr> <td>{{name}}</td> <td>{{price}}€</td> </tr> {{/each}} </mj-table> <mj-text> <p>Total : <strong>{{total}}€</strong></p> </mj-text> </mj-column> </mj-section> </mj-body></mjml>
Text version :
invoice.text
Hello {{name}} You'r Invoice : {{#each products}}- {{name}} : {{price}}€{{/each}} Total : {{total}}€
Subject of mail :
invoice.subject
{{name}}, you'r invoice is ready ;)
On start of you'r app, init mailik with you'r config :
const path = const mailik = mailik
And use
const mailik = const invoiceMail = // template name
Directory
All templates must has 3 versions :
- .subject
- .text
- .mjml if you use MJML, or .html
- /templates/directory/[nameOfTemplate].mjml
- /templates/directory/[nameOfTemplate].text
- /templates/directory/[nameOfTemplate].subject
Exemples :
- /templates/directory/welcome.mjml
- /templates/directory/welcome.text
- /templates/directory/welcome.subject
- /templates/directory/forgetPassword.mjml
- /templates/directory/forgetPassword.text
- /templates/directory/forgetPassword.subject
- /templates/directory/youHaveAMessage.mjml
- /templates/directory/youHaveAMessage.text
- /templates/directory/youHaveAMessage.subject