apemanmail

2.0.2 • Public • Published

apemanmail

Build Status Code Climate Code Coverage npm Version

Email sender.

Installation

$ npm install apemanmail --save

Usage

Setup email templates with handlebars like

  • mail/templates/password-reset.ja.hbs
  • mail/templates/password-reset.en.hbs

and env file like:

env/mail.json

{
  "default": {
    "MOCK": false
  },
  "production": {
    "SERVICE": "sendgrid",
    "SENDGRID_API_KEY": "as9d89y0asd8789asd;8ALKjkljc9897"
  },
  "staging": {
    "SERVICE": "sendgrid",
    "SENDGRID_API_KEY": "aas98dfu"
  },
  "development": {
    "MOCK": true
  },
  "test": {
    "MOCK": true
  }
}

then,

'use strict'
 
const apemanmail = require('apemanmail')
 
let mail = apemanmail({
  env: require('../env')('mail'),
  templates: `${__dirname}/*.hbs`,
  triggers: `${__dirname}/triggers/*_trigger.js`
})
 
mail.send({
  to: 'hoge@example.com',
  from: 'info@apeman.example.com',
  subject: '[apeman] Reset Your Password',
  text: mail.render('password-reset.ja', {
    url: 'http://apeman.example.com/reset/password?token=89rzs9e8r3niu'
  })
 
}, (err, result) => {
  /* ... */
})
 

License

This software is released under the MIT License.

Links

Readme

Keywords

Package Sidebar

Install

npm i apemanmail

Weekly Downloads

8

Version

2.0.2

License

MIT

Last publish

Collaborators

  • okunishinishi