2.0.0 • Published 9 years ago
@stoplight/feathers-mailer v2.0.0
feathers-mailer
Feathers mailer service using
nodemailer
Installation
npm install feathers-mailer --saveIf using a transport plugin, install the respective module.
API
import Mailer from 'feathers-mailer'
mailer = Mailer(transport, defaults)
transportcan be either SMTP options or a transport plugin with associated options.defaultsis 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.

