【发布时间】:2018-06-02 03:28:29
【问题描述】:
所以我有这个小型节点服务器,我尝试发送这样的电子邮件
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]: 在 Object._errnoException (util.js:1024:11)
app[web.1]:在 _exceptionWithHostPort (util.js:1046:20)
app[web.1]:在 TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
app[web.1]:代码:'ECONNECTION',
app[web.1]: errno: 'ECONNREFUSED',
app[web.1]: 系统调用: 'connect',
app[web.1]:地址:'127.0.0.1',
app[web.1]:端口:587,
app[web.1]: 命令:'CONN' }
谁能帮助我?提前致谢
【问题讨论】:
-
它适用于其他路线吗?这似乎与电子邮件无关,但与网络有关
-
看起来 nodemail 不再将服务作为选项。
-
也许 Heroku 阻止 smtp ?
标签: node.js express nodemailer