So i have this small node server where i try to send an email like this
app.post('/messaggio', function(req, res) {
var textMessage = req.body.message;
var transporter = nodemailer.createTransport({
Service : 'Gmail',
auth : {
user : '[email protected]',
pass : 'mypassword'
}
});
var mailOptions = {
from: '[email protected]',
to : '[email protected]',
subject : "My SUBJECT",
text : textMessage
}
transporter.sendMail(mailOptions, function(error, info) {
if(error) {
console.log(error);
}
else {
console.log("message sent");
}
});
});
I deplyed it on heroku but on /messaggio request i get this messages in the heroku logs:
app[web.1]: { Error: connect ECONNREFUSED 127.0.0.1:587
app[web.1]: at Object._errnoException (util.js:1024:11)
app[web.1]: at _exceptionWithHostPort (util.js:1046:20)
app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
app[web.1]: code: 'ECONNECTION',
app[web.1]: errno: 'ECONNREFUSED',
app[web.1]: syscall: 'connect',
app[web.1]: address: '127.0.0.1',
app[web.1]: port: 587,
app[web.1]: command: 'CONN' }
Can anyone help me? Thanks in advance