javascript - Node.js imap connection handling -


i need write node.js application keep checking if there new email imap server.

i trying write object handling imap connection.

var imap = require('imap'),     inspect = require('util').inspect; const fs = require('fs'); var mailparser = require("mailparser").mailparser;   var promise = require("bluebird");  function imapconnection(config){     if (!(this instanceof imapconnection))     return new imapconnection(config);     this._imap = new imap(config);     this._config = config; }  imapconnection.prototype.getimap = function(){     self = this;     if(this._imap.state !== 'authenticated'){         return new promise(function(resolve,reject){             self._imap.connect();             self._imap.once('ready', function(){                 resolve(self._imap);             });         });     }else{         return new promise(function(resolve,reject){resolve(this._imap);});     } }  

but when call object after called end() function of imap object never connects again , gives timeout error:

{ [error: timed out while connecting server] source: 'timeout' } [connection] closed events.js:141       throw er; // unhandled 'error' event       ^  error: timed out while connecting server     @ null._ontimeout  (/home/ctw/documents/nodejsmail/node_modules/imap/lib/connection.js:280:15)     @ timer.listontimeout (timers.js:92:15) 

can tell me what's wrong on code or other better practice? thanks.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -