Created
July 25, 2016 20:47
-
-
Save kkleidal/200631aacd02c11c998b2a8b55773778 to your computer and use it in GitHub Desktop.
Send Mail via SMTP with Node
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
/* 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