我在 Heroku 上使用 Nodemailer 时遇到问题,非常感谢您的帮助。
我的应用程序的先前版本曾经在 Heroku 上运行没有问题,当我回滚到该版本时,它仍然运行良好。在该应用程序的最新版本中,我没有对访问 Nodemailer 的代码进行任何更改,因此这对我来说没有任何意义。
Nodemailer的版本是:0.6.5
这是日志消息:
2015-02-18T04:29:57.730815+00:00 app[web.2]: POST /employer/53f44e3df4f8150200554eb7/job/ 200 32ms - 581b
2015-02-18T04:29:58.045066+00:00 app[web.2]: /app/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:918
2015-02-18T04:29:58.045069+00:00 app[web.2]: this._xoauth2.reconnectCount = 0;
2015-02-18T04:29:58.045070+00:00 app[web.2]: ^
2015-02-18T04:29:58.041300+00:00 app[web.2]: Exit callback being invoked
2015-02-18T04:29:58.045072+00:00 app[web.2]: TypeError: Cannot assign to read only property 'reconnectCount' of false
2015-02-18T04:29:58.045073+00:00 app[web.2]: at SMTPClient._actionAUTHComplete (/app/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:918:34)
2015-02-18T04:29:58.045075+00:00 app[web.2]: at SMTPClient._onData (/app/node_modules/nodemailer/node_modules/simplesmtp/lib/client.js:352:29)
2015-02-18T04:29:58.045076+00:00 app[web.2]: at TLSSocket.emit (events.js:107:17)
2015-02-18T04:29:58.045078+00:00 app[web.2]: at readableAddChunk (_stream_readable.js:163:16)
2015-02-18T04:29:58.045079+00:00 app[web.2]: at TLSSocket.Readable.push (_stream_readable.js:126:10)
2015-02-18T04:29:58.045080+00:00 app[web.2]: at TCP.onread (net.js:529:20)
2015-02-18T04:29:58.769185+00:00 heroku[web.2]: Process exited with status 1
2015-02-18T04:29:58.780771+00:00 heroku[web.2]: State changed from up to crashed
2015-02-18T04:29:58.780771+00:00 heroku[web.2]: State changed from crashed to starting
2015-02-18T04:30:00.371578+00:00 heroku[web.2]: Starting process with command `node app.js`
2015-02-18T04:30:01.904015+00:00 app[web.2]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
2015-02-18T04:30:01.904115+00:00 app[web.2]: Recommending WEB_CONCURRENCY=1
2015-02-18T04:30:02.288471+00:00 app[web.2]: Failed to load c++ bson extension, using pure JS version
2015-02-18T04:30:02.652326+00:00 app[web.2]: Started in PROD mode
2015-02-18T04:30:02.815284+00:00 app[web.2]: Express server listening on port 9622
2015-02-18T04:30:03.291115+00:00 heroku[web.2]: State changed from starting to up
我们可以看到它在“client.js”的第 918 行失败,错误如下:
类型错误:无法分配给 false 的只读属性“reconnectCount”。
为什么它会尝试将“false”分配给“reconnectCount”?
我的代码非常简单:
app.locals.smtpTransport = nodemailer.createTransport('SMTP', {
服务:“Gmail”,
授权:{
用户:“[电子邮件受保护] /cdn-cgi/l/email-protection“,
通过:“pass123”
}
});
然后我使用代码发送邮件,如下所示:
req.app.locals.smtpTransport.sendMail( ......
这段代码适用于我的 Heroku 暂存实例,因此这对我来说没有意义。
我已向 Heroku 记录了支持请求,我将转达您可以提供的任何指导。
非常感谢你的帮助。