1.2.0 • Published 4 years ago

notifizz v1.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Overview


const Notifizz = require('notifizz')

//Basic Configuration
Notifizz.config({
    mail: {
        host: 'smtp.mailtrap.io',
        port: 2525,
        secure: false,
        auth: {
            user: '---',
            pass: '---'
        },
        // from: 'User1 <user1@example.com>' //Set from address globally,
    },
    // viewsDirectory: '/views' // Set html views directory where you keep all html mail files, default: /views,
    templateEngine: 'ejs' // Default to null, means non-dynamic html or static html
})

const notifizz = new Notifizz

//Mail with plain text
notifizz
    .from('User2 <user2@example.com>') //Overrides global `from` config option
    .to('receiver@example.com')
    .subject("Your order with ID:1234567890 was successful!")
    .message('Hello, Your order was successful! Thanks')
    .send() //returns promise with response meta data

//Mail with static html.
notifizz
    .from('User2 <user2@example.com>') //Overrides global `from` config option
    .to('receiver@example.com')
    .subject("Your order with ID:1234567890 was successful!")
    .view('/emails/test-html-mail.ejs',)
    .send() //returns promise with response meta data

//Mail with dynamic html. here templating engine is ejs. Currently only ejs is supported. You need to set it manually from config options
notifizz
    .from('User2 <user2@example.com>') //Overrides global `from` config option
    .to('receiver@example.com')
    .subject("Your order with ID:1234567890 was successful!")
    .view('/emails/test-html-mail.ejs', { message: "This is dynamic html" }) //Default root directory: /views, you can change from config options with `viewsDirectory` option
    .send() //returns promise with response meta data