diff --git a/lib/imap.js b/lib/imap.js index 0d334ec..738d9d3 100644 --- a/lib/imap.js +++ b/lib/imap.js @@ -309,9 +309,9 @@ ImapConnection.prototype.connect = function(loginCb) { } if (indata.line[0] === '*') { // Untagged server response - var isUnsolicited = - (requests[0] && requests[0].cmd === 'NOOP') - || (state.isIdle && state.ext.idle.state !== IDLE_NONE); + var isUnsolicited = (requests[0] && requests[0].cmd === 'NOOP') + || (state.isIdle && state.ext.idle.state !== IDLE_NONE) + || !requests.length; if (m = XRegExp.exec(indata.line, REX_UNRESPNUM)) { // m.type = response type (numeric-based) m.type = m.type.toUpperCase(); @@ -321,8 +321,13 @@ ImapConnection.prototype.connect = function(loginCb) { // m.info = message details var data, parsed, headers, f, lenf, body, lenb, msg, bodies, details, val; + + isUnsolicited = isUnsolicited + || (requests[0] && requests[0].cmd !== 'FETCH'); + if (!isUnsolicited) bodies = parsers.parseFetchBodies(m.info, indata.literals); + details = new ImapMessage(); parsers.parseFetch(m.info, indata.literals, details); details.seqno = parseInt(m.num, 10);