【发布时间】: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