mail-listener2 doesn't work

前端 未结 2 1603
自闭症患者
自闭症患者 2021-01-12 05:02

This is my code for the mail-listener file.

I call the startListening function in my main file, and I can read \"Imap connected\" in the console , but then, even if

相关标签:
2条回答
  • 2021-01-12 05:51

    I had the same issue. The example doesn't work. I'm using mail-notifier instead:

    var notifier = require('mail-notifier');
    
    var imap = {
          user: "_example@example.com_",
          password: "password",
          host: "imap.gmail.com",
          port: 993,
          tls: true,
          tlsOptions: { rejectUnauthorized: false }
    };
    
    notifier(imap).on('mail',function(mail){
             console.log("GOT MAIL");
    }).start();
    

    Works like a charm

    0 讨论(0)
  • 2021-01-12 05:53

    For the snippet of code to work, remove the:

    searchFilter: "FLAGGED"
    

    Currently, you are just searching for unseen, flagged emails, and likely the incoming email is not flagged as important. I had the exact implementation above, without the FLAGGED search filter, and this works perfectly.

    0 讨论(0)
提交回复
热议问题