ImapFlow is a modern, promise-based IMAP client library for Node.js, designed to simplify interactions with IMAP servers without requiring deep protocol knowledge. It provides an async/await API, automatically handles various IMAP extensions (like CONDSTORE, QRESYNC, IDLE, COMPRESS), and supports message streaming, mailbox locking, and proxy configurations. The current stable version is `1.3.2`. Releases appear to be frequent, with multiple patch and minor versions released monthly, indicating active development and maintenance. Key differentiators include its automatic IMAP extension handling, built-in mailbox locking for concurrent access, and comprehensive TypeScript support, making it robust for complex email processing applications. It also features specific support for Gmail labels and raw search queries via X-GM-EXT-1.
npm install imapflowVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates connecting to an IMAP server, acquiring a mailbox lock, fetching the latest message's raw source, and iterating through all messages to log their subjects, ensuring proper resource cleanup.
Wrap operations requiring a mailbox lock in a `try...finally` block to guarantee `lock.release()` is called, even if errors occur.
Review the 'Configuration' and 'Quick Start' guides on imapflow.com, especially for services like Gmail, Outlook, and Yahoo, to ensure correct options and practices are applied.
Upgrade to the latest `imapflow` version (>=1.3.0) to benefit from fixes for unhandled promise rejections. Implement comprehensive error handling around `client.connect()`, `client.logout()`, and `IDLE` operations.
When performing complex search queries, especially with `OR` or `NOT` conditions, ensure they are properly parenthesized according to RFC 3501. Upgrade to `v1.2.16` or newer to get automatic parenthesization for compound conditions.
Verify credentials. For Gmail, ensure 'Less secure app access' is enabled or use an App Password if 2FA is on. Double-check `auth.user` and `auth.pass` in the ImapFlow client configuration.
Use `client.listMailboxes()` to get a list of available mailboxes and verify the correct name. IMAP mailbox names are case-sensitive on some servers.
Ensure `new ImapFlow(...)` is called and `await client.connect()` successfully completes before performing any IMAP operations like `fetchOne` or `fetch`.
Always `await` ImapFlow's promise-returning methods or attach a `.catch()` handler to them to prevent unhandled promise rejections. Wrap your main async logic in a function and call it with `.catch(console.error)`.
No dependency data recorded yet.