New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

mailik

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mailik

Send mail from templates

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

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 = require('path')
const mailik = requrie('mailik')

mailik.init({
  directory: path.join(__dirname, './templates'),
  mail: {
    /* default config for mail */
    from: 'John Doe <admin@exemple.com>',
  },
  nodemailer: {
    /* nodemailer transport config */
    host: 'smtp.domain.com',
    port: 25,
    auth: {
      user: 'xxxxxxxxxxxxxxxx',
      pass: 'xxxxxxxxxxxxxxxx',
    },
  },
})

And use

const mailik = require('mailik')

const invoiceMail = mailik('invoice') // template name

invoiceMail('to@exemple.com', {
  name: 'Simon',
  products: [
    { name: 'Product A', price: 42 },
    { name: 'Product B', price: 4242 },
  ],
  total: 4284,
})
  .then((infos) => {
    console.log(infos)
  })
  .catch((err) => {
    console.error(err)
  })

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

Keywords

mail

FAQs

Package last updated on 18 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts