Fix for IMAP node - inbox 0 error.

This commit is contained in:
Dave C-J 2014-03-23 11:43:34 +00:00
parent 0b516a83db
commit 2a0491542d
1 changed files with 44 additions and 39 deletions

View File

@ -57,7 +57,7 @@ function ImapNode(n) {
imap.once('ready', function() {
var pay = {};
openInbox(function(err, box) {
//if (err) throw err;
if (box.messages.total > 0) {
var f = imap.seq.fetch(box.messages.total + ':*', { bodies: ['HEADER.FIELDS (FROM SUBJECT DATE)','TEXT'] });
f.on('message', function(msg, seqno) {
node.log('message: #'+ seqno);
@ -102,6 +102,11 @@ function ImapNode(n) {
else { node.log('duplicate not sent: '+pay.topic); }
imap.end();
});
}
else {
// node.log("you have achieved inbox zero");
imap.end();
}
});
});
imap.connect();