Heroku与NodeMailer问题 [英] Heroku issue with NodeMailer

查看:118
本文介绍了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]:退出回调正在被调用
2015-02-18T04:29:58.045072 + 00:00 app [web.2]:TypeError:不能分配给只读属性'reconnectCount'为false
2015-02-18T04: 29:58.045073 + 00:00 app [web.2]:在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]:在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]:在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)
2 015-02-18T04:29:58.769185 + 00:00 heroku [web.2]:进程退出状态1
2015-02-18T04:29:58.780771 + 00:00 heroku [web.2]:状态变更为坠毁
2015-02-18T04:29:58.780771 + 00:00 heroku [web.2]:从坠毁状态变为开始
2015-02-18T04:30:00.371578 + 00 :00 heroku [web.2]:使用命令`node app.js`启动程序
2015-02-18T04:30:01.904015 + 00:00应用程序[web.2]:检测到512 MB可用内存,512每个进程的MB限制(WEB_MEMORY)
2015-02-18T04:30:01.904115 + 00:00应用[web.2]:推荐WEB_CONCURRENCY = 1
2015-02-18T04:30:02.288471 + 00 :00 app [web.2]:无法加载c ++ bson扩展,使用纯JS版本
2015-02-18T04:30:02.652326 + 00:00 app [web.2]:以PROD模式启动
2015-02-18T04:30:02.815284 + 00:00 app [web.2]:监听端口9622的快递服务器
2015-02-18T04:30:03.291115 + 00:00 heroku [web.2 ]:状态从开始变为向上

我们可以看到它在客户端918行失败.js文件错误:

TypeError:无法分配给只读属性'reconnectCount'为false。



为什么它会尝试将'false'分配给'reconnectCount'吗?



我的代码很简单:

app.locals.smtpTransport = nodemailer.createTransport('SMTP',{
服务:'Gmail',
验证:{
用户:example@gmail.com,
pass:pass123
}
});
然后我使用代码发送邮件,如:



req.app.locals.smtpTransport.sendMail(......



此代码适用于Heroku的暂存实例,因此对我来说没有意义。



我记录了一个支持请求与Heroku和任何指导,你可以提供我会传递给他们。

非常感谢您的帮助。

你可能在iojs中运行Nodemailer,最新版本的Nodemailer支持节点0.12和iojs,因此您应该像这样升级或修复918行:

  if(this._xoauth2){
this._xoauth2.reconnectCount = 0;
}



在ES5中允许将属性设置为布尔值,但iojs运行ES6并尝试在ES6严格模式下设置属性时会抛出错误。

b $ b

我想我已经通过明确地将我的包文件中的node.js版本设置为使用ES5的较旧版本来解决这个问题。



这已解决了我的问题。获得的教训是始终在包文件中设置nodejs版本,否则Heroku会使用最新版本,并且可能与您的模块不兼容。



非常感谢Nodemailer,他们得到了回到我身边的超级快速反应良好。



希望这可以帮助别人。



谢谢。 / p>

I am having an issue with Nodemailer on Heroku and I would really appreciate your help.

A previous version of my application used to work on Heroku with no problem and when I roll back to that version, it still works fine. In the latest version of the application, I have made no changes to the code accesses Nodemailer so this doesn't really make sense to me.

The version of nodemailer is: 0.6.5

Here is the log message:

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

We can see that it is failing on line 918 of 'client.js' with the error of:

TypeError: Cannot assign to read only property 'reconnectCount' of false.

Why would it be trying to assign 'false' to 'reconnectCount'?

My code is really simple:

app.locals.smtpTransport = nodemailer.createTransport('SMTP', { service: 'Gmail', auth: { user: "example@gmail.com", pass: "pass123" } }); I then use the code to send mail like:

req.app.locals.smtpTransport.sendMail( ......

This code works on my staging instance of Heroku so that doesn't make sense to me.

I have logged a support request with Heroku and any guidance that you can provide I will pass onto them.

Thanks so much for your help.

解决方案

I just got the following response back from Nodemailer:

You are probably running Nodemailer in iojs. Only the latest version of Nodemailer is suported in node 0.12 and iojs, so you should either upgrade or fix the line 918 yourself like this:

if(this._xoauth2){
    this._xoauth2.reconnectCount = 0;
}

Setting properties to boolean values was allowed in ES5 but iojs runs ES6 and trying to set a property in ES6 strict mode throws an error.

I think I have fixed this by by explicitly setting the node.js version in my package file to an older version that uses ES5.

This has fixed my problem. Lesson learned is to always set the nodejs version in the package file otherwise Heroku uses the latest version and it may be incompatible with your modules.

Many thanks to Nodemailer, they got back to me super quick with a great response.

Hopefully this will help someone else.

Thanks.

这篇关于Heroku与NodeMailer问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆