Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How often does the node.js mail-listener poll the email box?

Tags:

node.js

I'm looking at this node.js code that sets up a mail listener on an email box that I have specified. It works.

However I want to know how often this polls the inbox in question. That's what I don't know and that seems not to be specified anywhere. So how can I find out what the polling period is? Is it even polling? If not how else does get emails as they arrive?

var MailListener = require("mail-listener2");
var mailListenerOptions = {
    username: "myUserName",
    password: "myPassword",
    host:     "myHost.com",
    port:     993,
    tls: true,
    tlsOptions: { rejectUnauthorized: false },
    mailbox: "INBOX",
    markSeen: true,
    fetchUnreadOnStart: true,
    mailParserOptions: {streamAttachments: true}
};


var startServer = function(req, res){
    var mailListener = new MailListener(mailListenerOptions);
    mailListener.on("server:connected", function(){
        // Do something
    });
    mailListener.on("server:disconnected", function(){
        // Do something
    });
    mailListener.on("error", function(error){
        // Do something
    });

    mailListener.start();
    mailListener.on("mail", processEmail);
}

var processEmail = function(mail){
    // Do something
}
like image 239
Saqib Ali Avatar asked Mar 20 '23 22:03

Saqib Ali


2 Answers

mail-listener2 works on the IMAP protocol. It works like your Outlook mail client to receive mails. If your mail server supports the IMAP IDLE protocol, you should get message notifications from the servers as a "push notification" rather than a response to continuous polling.

like image 102
Munim Avatar answered Mar 23 '23 12:03

Munim


Short answer: you'll get updates immediately.

like image 33
mcont Avatar answered Mar 23 '23 10:03

mcont