Return a promise that resolves when the IMAP account box has opened.
This module takes an instance of the imap module, and returns a promise which resolves when the box (folder) information is retrieved, or rejects if an error occurs.
const Imap = require('imap')
const openBox = require('imap-open-box')
const imap = new Imap({
user: 'me@gmail.com',
password: 'abc123',
host: 'imap.gmail.com',
port: 993,
tls: true
})
imap.once('ready', () => {
openBox({ imap, box: 'INBOX' })
.then(details => {
// information about the box
})
})
imap.on('error', error => {
console.log(error)
})
imap.once('end', () => {
console.log('connection ended!')
})
imap.connect()The module takes an object with the following properties:
The instance of imap provided must be instantiated and
have already emitted the ready event.
The name of the box to open, e.g. INBOX or INBOX.archive.
Whether to open the box as read-only or not.
- The promise resolves with an object of the box information.
- The promise rejects with an error as given by the imap module.
Published and released under the VOL.