Created
May 5, 2016 16:24
-
-
Save mobarrio/54d588b6078c04ea55a50108e713e198 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 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); | |
}); | |
} | |
}); |
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
{ | |
"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