nodemailer-sendgrid-transport / 0.1.0 last updated 2 months ago created on Jul 15th 2014

Install

npm install --save nodemailer-sendgrid-transport

Clone

git clone git@github.com:sendgrid/nodemailer-sendgrid-transport.git

dependencies show all 31

main sendgrid 1.2.1 MIT

maintainers

eddiezane eddiezane
scottmotte scottmotte
nquinlan nquinlan
elbuo8 elbuo8

versions

0.1.0 2 months ago eddiezane
0.0.2 5 months ago eddiezane
0.0.1 5 months ago eddiezane
13 Downloads yesterday.

readme

nodemailer-sendgrid-transport

This module is a transport plugin for Nodemailer that makes it possible to send through SendGrid's Web API!

Usage

Install via npm.

npm install nodemailer-sendgrid-transport

Require the module and initialize it with your SendGrid credentials.

var nodemailer = require('nodemailer');
var sgTransport = require('nodemailer-sendgrid-transport');

var options = {
    auth: {
        api_user: 'SENDGRID_USERNAME',
        api_key: 'SENDGRID_PASSWORD'
    }
}

var mailer = nodemailer.createTransport(sgTransport(options));

Note: We suggest storing your SendGrid username and password as enviroment variables.

Create an email and send it off!

var email = {
    to: ['joe@foo.com', 'mike@bar.com'],
    from: 'roger@tacos.com',
    subject: 'Hi there',
    text: 'Awesome sauce',
    html: '<b>Awesome sauce</b>'
};

mailer.sendMail(email, function(err, res) {
    if (err) { 
        console.log(err) 
    }
    console.log(res);
});

License

Licensed under the MIT License.

Resolving all dependencies.. This could take a while as our cache is not yet fully warmed up.