resilient-mailer-sendgrid

0.1.4 • Public • Published

resilient-mailer-sendgrid

resilient-mailer-sendgrid implements SendGrid as an email provider for resilient-mailer.

NPM Version Build Status Coverage Status

var SendgridProvider = require('resilient-mailer-sendgrid');
 
var sendgrid = new SendgridProvider('MyApiUser', 'MyApiKey');
 
var mailer; // ResilientMailer instance
mailer.registerProvider(sendgrid);

Installation

$ npm install resilient-mailer-sendgrid

Usage

Create an instance of the provider. There are also a number of options you can alter:

var SendgridProvider = require('resilient-mailer-sendgrid');
 
var options = {
    apiSecure: false,         // allows the use of HTTP rather than HTTPS
    apiHostname: '127.0.0.1', // allows alternative hostname
    apiPort: 8080             // allows unusual ports
};
 
var sendgrid = new SendgridProvider('MyApiUser', 'MyApiKey', options);

To register the provider with your ResilientMailer instance:

var mailer; // ResilientMailer instance
mailer.registerProvider(sendgrid);

In the event that you want to use SendgridProvider directly (rather than the usual way - via ResilientMailer):

var message = {
    from: 'no-reply@example.com',
    to: ['user@example.net'],
    subject: 'Testing my new email provider',
    textBody: 'Seems to be working!',
    htmlBody: '<p>Seems to be working!</p>'
};
 
sendgrid.send(message, function (error) {
    if (!error)
        console.log('Success! The message sent successfully.');
 
    else
        console.log('Message sending failed - ' + error.message);
});

To see everything available in the message object, refer to resilient-mailer.

Testing

Install the development dependencies first:

$ npm install

Then the tests:

$ npm test

Support

Please open an issue on this repository.

Authors

License

MIT licensed - see LICENSE file

Readme

Keywords

none

Package Sidebar

Install

npm i resilient-mailer-sendgrid

Weekly Downloads

1

Version

0.1.4

License

MIT

Last publish

Collaborators

  • billinghamj