I\'d like to send mails on my local server but it seems not working with Nodemailer and NodeJS.
Is there any solutions to send mails from local?
var nodemailer = require('nodemailer');
// Create a SMTP transport object
var transport = nodemailer.createTransport("SMTP", {
service: 'Hotmail',
auth: {
user: "username",
pass: "password"
}
});
// Message object
var message = {
// sender info
from: 'name@hotmail.com',
// Comma separated list of recipients
to: req.query.to,
// Subject of the message
subject:req.query.subject, //'Nodemailer is unicode friendly ✔',
// plaintext body
text: req.query.text //'Hello to myself!',
// HTML body
/* html:'Hello to myself 
'+
'Here\'s a nyan cat for you as an embedded attachment:
'*/
};
console.log('Sending Mail');
transport.sendMail(message, function(error){
if(error){
console.log('Error occured');
console.log(error.message);
return;
}
console.log('Message sent successfully!');
// if you don't want to use this transport object anymore, uncomment
//transport.close(); // close the connection pool
});
You must specify the transport protocol like that of SMTP or create youy own transport.You have not specified this in you code.