apemanmail

Email sender.

Usage no npm install needed!

<script type="module">
  import apemanmail from 'https://cdn.skypack.dev/apemanmail';
</script>

README

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