@danfebooks/nodemailer-sendgrid-transport

    0.4.0 • Public • Published

    Why

    For some reason, we need to use SendGrid V3 in SailJS < 1.0.x

    nodemailer-sendgrid-transport

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

    npm version

    Usage

    Install via npm.

    npm install -S -E @danfebooks/nodemailer-sendgrid-transport
    

    Require the module and initialize it with your SendGrid credentials.

    Recommended to use with @danfebooks/sails-service-mailer

    var nodemailer = require('nodemailer');
    var sgTransport = require('@danfebooks/nodemailer-sendgrid-transport');
    
    // api key https://sendgrid.com/docs/Classroom/Send/api_keys.html
    var options = {
    	auth: {
    		api_key: 'SENDGRID_APIKEY'
    	}
    }
    	
    var mailer = nodemailer.createTransport(sgTransport(options));

    Note: serve the API KEY using environment 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>',
    	categories: ['Welcome Email', 'Receipt Email']
    };
    
    mailer.sendMail(email, function(err, res) {
    	if (err) { 
    		console.log(err) 
    	}
    	console.log(res);
    });

    Need help?

    Please file an issue.

    Install

    npm i @danfebooks/nodemailer-sendgrid-transport

    DownloadsWeekly Downloads

    2

    Version

    0.4.0

    License

    MIT

    Unpacked Size

    7.6 kB

    Total Files

    9

    Last publish

    Collaborators

    • avatar
    • avatar