async fetchOneFullMail(to, uid) { if (!this.connection) { // Here we 'fail fast' instead of waiting for the connection. throw new Error('imap connection not ready') } debug(`fetching full message ${uid}`) // For security we also filter TO, so it is harder to just enumerate all messages. const searchCriteria = [['UID', uid], ['TO', to]] const fetchOptions = { bodies: ['HEADER', ''], // Empty string means full body markSeen: false } const messages = await this.connection.search(searchCriteria, fetchOptions) if (messages.length === 0) { throw new Error('email not found') } const fullBody = _.find(messages[0].parts, {which: ''}) return simpleParser(fullBody.body) }