Search code examples
node.jsnotificationsgmailimapgmail-imap

imap credentials not working when listening to new mail event using node mail-notifier2 module


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();

I am trying to listen to new mail event in my gmail inbox. I am using node mail-notifier2 module to do so (as shown in code snippet above). However, I am not able to authenticate.

When I am using above code I get error:-'uncaughtException: Timed out while authenticating with server' and when I am passing tls: true in imap object then I get uncaught exception: 'uncaughtException: self signed certificate in certificate chain'. Please let me know where I am wrong and what should I do to make this work?


Solution

  • This issue has been resolved in this forum: https://github.com/request/request/issues/2061

    As answered The trick is to set process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; With that fake SSL auth can be used to inspect client and server communications