Add proxy alongside the mailbox settings when ImapFlow should reach an IMAP server through an HTTP CONNECT proxy:

import { ImapFlow } from 'imapflow';

const client = new ImapFlow({
  host: 'imap.example',
  port: 993,
  secure: true,
  auth: mailboxCredentials,
  proxy: 'http://proxy.example:8080',
});

mailboxCredentials holds the application's IMAP account. Use this client for the existing connect, mailbox work and logout or failure-cleanup sequence. For a publicly reachable mail service where a public intermediary is permitted, the HTTP proxy list supplies candidates for the proxy URL without proxy credentials; check access to the actual IMAP host and port.

Two details worth checking

  • The tunnel port is 993. The proxy must permit CONNECT to imap.example:993. An intermediary allowing website tunnels only on 443 can reject this request even with valid proxy credentials.
  • The mailbox remains TLS-protected. secure: true applies to the mailbox connection. The proxy URL's http scheme identifies the intermediary listener, not a replacement for the IMAP hostname.

If the intermediary needs a login, supply its account through ImapFlow's supported proxy URL format. Keep the mailbox account in auth. This example uses the standard Node proxy path; ImapFlow's custom runtime transport cannot be combined with proxy.

Artihkkalat mat laktásit