Last active
February 19, 2016 14:48
-
-
Save ws/1ad42be3b987f9c6ba17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = nodemailer.createTransport({ | |
service: 'SendGrid', | |
auth: { | |
user: 'SENDGRID_USERNAME', | |
pass: 'SENDGRID_PASSWORD' | |
} | |
}); | |
// See above |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nodemailer = require('nodemailer'); | |
var sgTransport = require('nodemailer-sendgrid-transport'); | |
var options = { | |
auth: { | |
api_user: 'SENDGRID_USERNAME', | |
api_key: 'SENDGRID_PASSWORD' | |
} | |
} | |
var client = nodemailer.createTransport(sgTransport(options)); | |
var email = { | |
from: 'awesome@bar.com', | |
to: 'mr.walrus@foo.com', | |
subject: 'Hello', | |
text: 'Hello world', | |
html: '<b>Hello world</b>' | |
}; | |
client.sendMail(email, function(err, info){ | |
if (err ){ | |
console.log(error); | |
} | |
else { | |
console.log('Message sent: ' + info.response); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would it be possible to use a SendGrid template instead of:
var email = { from: 'awesome@bar.com', to: 'mr.walrus@foo.com', subject: 'Hello', text: 'Hello world', html: '<b>Hello world</b>' };