【问题标题】:imap credentials not working when listening to new mail event using node mail-notifier2 module使用 node mail-notifier2 模块收听新邮件事件时,imap 凭据不起作用
【发布时间】:2017-10-06 02:50:46
【问题描述】:
var notifier = require('mail-notifier');   
    var imap = {
           username: "siddharthsogani1",
           password: "MYGMAILPASSWORD",
           host: "imap.gmail.com",
           port: 993, // imap port 
           secure: true // use secure connection 
    };

notifier(imap).on('mail',function(mail){console.log(mail);}).start();

我正在尝试在我的 gmail 收件箱中收听新邮件事件。我正在使用 node mail-notifier2 模块来执行此操作(如上面的代码 sn-p 所示)。但是,我无法进行身份验证。

当我使用上面的代码时,我得到错误:-'uncaughtException: Timed out while authentication with server' 当我在 imap 对象中传递 tls: true 时,我得到未捕获的异常:'uncaughtException:证书链中的自签名证书'。请让我知道我哪里错了,我应该怎么做才能完成这项工作?

【问题讨论】:

  • 由于您使用的是 NodeJS,请尝试 NodeJS Quickstart for Gmail 并遵循 OAuth 流程。关于错误,请检查此github forum,其中建议的替代方法是 a) 在负载均衡器上终止 SSL b) 使用免费证书。
  • @noogui 非常感谢! github论坛帮助了:)

标签: node.js notifications gmail imap gmail-imap


【解决方案1】:

此问题已在本论坛解决:https://github.com/request/request/issues/2061

正如回答的诀窍是设置 process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; 有了这个伪造的 SSL 身份验证,就可以用来检查客户端和服务器的通信

【讨论】:

    猜你喜欢
    • 2019-07-05
    • 2018-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-18
    • 2019-05-26
    • 2021-07-15
    • 2014-04-01
    相关资源
    最近更新 更多