@stoplight/feathers-mailer

Feathers mailer service

Usage no npm install needed!

<script type="module">
  import stoplightFeathersMailer from 'https://cdn.skypack.dev/@stoplight/feathers-mailer';
</script>

README

feathers-mailer

Build Status Code Climate Test Coverage Dependency Status Download Status Slack Status

Feathers mailer service using nodemailer

Installation

npm install feathers-mailer --save

If using a transport plugin, install the respective module.

API

import Mailer from 'feathers-mailer'

mailer = Mailer(transport, defaults)

  • transport can be either SMTP options or a transport plugin with associated options.
  • defaults is an object that defines default values for mail options.

mailer.create(body, params)

mailer.create is a thin wrapper for transporter.sendMail, accepting body and returning err and info.

See here for possible fields of body.

Example

import Mailer from 'feathers-mailer'
import mandrill from 'nodemailer-mandrill-transport'

// Register the service, see below for an example
app.use('/mailer', Mailer(mandrill({
  auth: {
    apiKey: process.env.MANDRILL_API_KEY
  }
})));

// Use the service
var email = {
   from: 'FROM_EMAIL',
   to: 'TO_EMAIL',
   subject: 'Sendgrid test',
   html: 'This is the email body'
};

app.service('mailer').create(email).then(function (result) {
  console.log('Sent email', result);
}).catch(err => {
  console.log(err);
});

For a more complete example, see examples/app which can be run with npm run example.

Changelog

1.0.0

  • Initial release

License

Copyright (c) 2016

Licensed under the MIT license.