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
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
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.