Skip to content

Instantly share code, notes, and snippets.

@ws
Last active February 19, 2016 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ws/1ad42be3b987f9c6ba17 to your computer and use it in GitHub Desktop.
Save ws/1ad42be3b987f9c6ba17 to your computer and use it in GitHub Desktop.
var client = nodemailer.createTransport({
service: 'SendGrid',
auth: {
user: 'SENDGRID_USERNAME',
pass: 'SENDGRID_PASSWORD'
}
});
// See above
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);
}
});
@pistiolasm
Copy link

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>' };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment