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
}
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.
Short answer: you'll get updates immediately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With