Skip to content

Instantly share code, notes, and snippets.

@mobarrio
Created May 5, 2016 16:24
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 mobarrio/54d588b6078c04ea55a50108e713e198 to your computer and use it in GitHub Desktop.
Save mobarrio/54d588b6078c04ea55a50108e713e198 to your computer and use it in GitHub Desktop.
var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');
var transporter = nodemailer.createTransport(smtpTransport({
host: 'host.nombre.com',
port: 465,
secure: true,
tls: { rejectUnauthorized: false },
debug: false,
logger: false,
auth: {
user: 'no_reply@nombre.com',
pass: 'xxxxxxxxxxxxxx'
}
}));
transporter.verify(function(error, success) {
if (error) {
console.log(error);
} else {
console.log('Server is ready to take our messages');
var mailOptions = {
from: '"NO-REPLY" <no_reply@nombre.com>',
to: 'cuenta1@nombre.com, cuenta2@nombre.com',
subject: 'Test desde NodeMailer',
text: 'Test desde NodeMailer ',
html: '<b>Test desde NodeMailer</b>'
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
}
});
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"nodemailer": "^2.3.2",
"nodemailer-smtp-transport": "^2.4.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment