Skip to content

Instantly share code, notes, and snippets.

@kkleidal
Created July 25, 2016 20:47
Show Gist options
  • Save kkleidal/200631aacd02c11c998b2a8b55773778 to your computer and use it in GitHub Desktop.
Save kkleidal/200631aacd02c11c998b2a8b55773778 to your computer and use it in GitHub Desktop.
Send Mail via SMTP with Node
/* jshint node: true */
"use strict";
var nodemailer = require('nodemailer');
// create reusable transporter object using the default SMTP transport
var transporter = nodemailer.createTransport({
host: "smtp.zoho.com",
// port: 587,
secure: true,
// requireTLS: true,
auth: {
user: "[email protected]",
pass: "YOUR_PASSWORD_HERE"
}
});
// setup e-mail data with unicode symbols
var mailOptions = {
from: 'Posh Development <[email protected]>', // sender address
to: '[email protected]', // list of receivers
subject: 'Hello', // Subject line
text: 'Hello world', // plaintext body
html: 'Hello world' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment