所以我有这个小节点服务器,我尝试发送这样的电子邮件
app.post('/messaggio', function(req, res) {
var textMessage = req.body.message;
var transporter = nodemailer.createTransport({
Service : 'Gmail',
auth : {
user : 'myemail01@gmail.com',
pass : 'mypassword'
}
});
var mailOptions = {
from: 'myemail@gmail.com',
to : 'receiver3@gmail.com',
subject : "My SUBJECT",
text : textMessage
}
transporter.sendMail(mailOptions, function(error, info) {
if(error) {
console.log(error);
}
else {
console.log("message sent");
}
});
});
我在heroku上把它删了,但在/ messaggio请求我在heroku日志中收到这些消息:
app [web.1]:{错误:连接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]:在TCPConnectWrap.afterConnect [as oncomplete](net.js:1182:14)
app [web.1]:代码:'ECONNECTION',
app [web.1]:错误:'ECONNREFUSED',
app [web.1]:系统调用:'connect',
app [web.1]:地址:'127.0.0.1',
app [web.1]:port:587,
app [web.1]:命令:'CONN'}
任何人都可以帮助我吗?提前致谢
答案 0 :(得分:0)
试
var transporter = nodeMailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user: 'youremail@gmail.com',
pass: 'password'
}
});