2.0.0 • Published 8 years ago
seneca-sendgrid-mail v2.0.0
seneca-sendgrid-mail
Seneca SendGrid email plugin.
This is a module for the Seneca microservices toolkit. It's a plugin extension for seneca-mail to enable sending emails via SendGrid.
Visit the seneca-mail page for full usage documention.
Requires Node.js >= 8
Installation
$ npm i seneca
$ npm i seneca-mail
$ npm i seneca-sendgrid-mailUsage
'use strict'
const seneca = require('seneca')()
const mail = require('seneca-mail')
const sendgridMail = require('seneca-sendgrid-mail')
const sendgridOptions = {
  key: 'YOUR_SENDGRID_API_KEY',
  tag: 'seneca-sendgrid-mail'
}
const email = {
  role: 'mail',
  cmd: 'send',
  text: 'Hi There!',
  to: 'alice@example.com',
  from: 'bob@example.com',
  subject: 'Greetings!'
}
seneca.use(mail)
seneca.use(sendgridMail, sendgridOptions)
seneca.ready(error => {
  if (error) {
    return console.log(error)
  }
  seneca.act(email, (err, response) => {
    if (err) {
      return console.error(err)
    }
    console.log(response)
  })
})Thx
- seneca-postmark-mail - for inspiration
License
