This package has been deprecated

Author message:

This module is no longer maintained. Use feathers-mailer with nodemailer-mailgun-transport instead

feathers-mailgun

0.1.2 • Public • Published

feathers-mailgun

A Mailgun Service for FeatherJS.

TODO

  • Better example
  • Lock down so mailer service is not exposed externally, maybe even by default for security reasons

Installation

npm install mailgun-js feathers-mailgun --save

Documentation

 
// Register the service, see below for an example
app.use('/mailer', mailgunService({
    apiKey: "YOUR_MAILGUN_API_KEY",
    domain: 'YOUR_MAILGUN_DOMAIN' // ex. your.domain.com
  }
));
 
// Use the service
var email = {
   from: 'FROM_EMAIL',
   to: 'TO_EMAIL',
   subject: 'Mailgun 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);
});
 

Complete Example

Here's an example of a Feathers server with a mailer Mailgun service.

import rest = from 'feathers-rest';
import feathers from 'feathers';
import bodyParser from 'body-parser';
import mailgunService from '../lib';
 
 
// Create a feathers instance.
var app = feathers()
  // Enable REST services
  .configure(rest())
  // Turn on JSON parser for REST services
  .use(bodyParser.json())
  // Turn on URL-encoded parser for REST services
  .use(bodyParser.urlencoded({extended: true}));
 
// Register the Mailgun service
app.use('/mailer', mailgunService({
    apiKey: "YOUR_MAILGUN_API_KEY",
    domain: 'YOUR_MAILGUN_DOMAIN' // ex. your.domain.com
  }
));
 
// Use the service
var email = {
   from: 'FROM_EMAIL',
   to: 'TO_EMAIL',
   subject: 'Mailgun 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);
});
 
// Start the server.
var port = 3030;
app.listen(port, function() {
  console.log(`Feathers server listening on port ${port}`);
});

You can run this example by using node examples/app. Make sure you've added your

License

Copyright (c) 2016

Licensed under the MIT license.

Author

Cory Smith

Package Sidebar

Install

npm i feathers-mailgun

Weekly Downloads

48

Version

0.1.2

License

MIT

Last publish

Collaborators

  • corymsmith
  • daffl
  • ekryski