Skip to content

ImapClient

Defined in: packages/net-imap/src/imap/imap-client.ts:84

IMAP4rev1 client over any transport.

Handles CRLF framing, tagged command correlation and untagged response collection. Tags are generated automatically by the high-level methods; use command with an explicit tag for finer control.

Correlation scans several outstanding commands rather than only the oldest, because a server may complete pipelined commands out of order.

Untagged lines and the greeting are dispatched as push events; subscribe before the first byte arrives to catch the greeting.

new ImapClient(source, options?): ImapClient

Defined in: packages/net-imap/src/imap/imap-client.ts:94

Transport

Any Transport. For a Node.js Duplex/net.Socket, wrap it first: new DuplexTransport(socket) from @ac-kit/net-transport-node.

ImapClientOptions

Buffer, line-length, pipelining and timeout tuning.

ImapClient

Session<string, string, ImapClientEvents>.constructor

get buffered(): number

Defined in: packages/net-core/src/session.ts:243

Bytes received but not yet decoded.

number

Session.buffered


get pendingExchanges(): number

Defined in: packages/net-core/src/session.ts:248

Number of outstanding exchanges, including abort tombstones.

number

Session.pendingExchanges

[asyncDispose](): Promise<void>

Defined in: packages/net-core/src/session.ts:277

Destroys the session, so it can be used with await using.

Promise<void>

Session.[asyncDispose]


capability(options?): Promise<ImapResponse>

Defined in: packages/net-imap/src/imap/imap-client.ts:167

Send CAPABILITY.

ExchangeOptions<string>

Abort, timeout and abort-policy overrides.

Promise<ImapResponse>


command(tag, cmd, options?): Promise<ImapResponse>

Defined in: packages/net-imap/src/imap/imap-client.ts:116

Send TAG CMD and collect every line up to the tagged response.

string

The command tag to correlate on.

string

The command and its arguments.

ExchangeOptions<string>

Abort, timeout and abort-policy overrides.

Promise<ImapResponse>

The tagged response with all preceding untagged lines.

If the tagged status is not OK, NO or BAD.


destroy(error?): void

Defined in: packages/net-core/src/session.ts:271

Tear the session down, rejecting every outstanding exchange.

Rejection happens here rather than relying on the transport emitting close, so callers are never left with promises that hang against a transport that closes silently.

unknown

Optional cause reported to outstanding exchanges.

void

Session.destroy


end(): Promise<void>

Defined in: packages/net-core/src/session.ts:258

Half-close the outbound direction and flush pending writes.

Prefer this over destroy for protocols with a farewell command, so the peer sees an orderly shutdown.

Promise<void>

Session.end


isSubscribed<K>(event, listener): boolean

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:38

Check if a callback is subscribed to a specific event.

K extends "push" | keyof BaseSessionEvents

K

The event name.

Callable<ImapClientEvents[K]>

The callback to check.

boolean

Session.isSubscribed


login(user, password, options?): Promise<ImapResponse>

Defined in: packages/net-imap/src/imap/imap-client.ts:136

Send LOGIN user password, quoting both as IMAP quoted strings.

string

The account name.

string

The account password.

ExchangeOptions<string>

Abort, timeout and abort-policy overrides.

Promise<ImapResponse>


logout(options?): Promise<ImapResponse>

Defined in: packages/net-imap/src/imap/imap-client.ts:177

Send LOGOUT.

ExchangeOptions<string>

Abort, timeout and abort-policy overrides.

Promise<ImapResponse>

The BYE line plus the tagged response.


nextTag(): string

Defined in: packages/net-imap/src/imap/imap-client.ts:199

Generate the next sequenced tag.

string

A tag of the form A0001.


select(mailbox, options?): Promise<ImapResponse>

Defined in: packages/net-imap/src/imap/imap-client.ts:155

Send SELECT mailbox.

string

The mailbox name.

ExchangeOptions<string>

Abort, timeout and abort-policy overrides.

Promise<ImapResponse>

The reply including untagged EXISTS, FLAGS and similar lines.


subscribe<K>(event, listener, options?): Callable | null

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:23

K extends "push" | keyof BaseSessionEvents

K

Callable<ImapClientEvents[K]>

EventDispatcherSubscribeOptions

Callable | null

Session.subscribe


unsubscribe<K>(event, listener): void

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:31

Unsubscribe a callback from a specific event.

K extends "push" | keyof BaseSessionEvents

K

The event name.

Callable<ImapClientEvents[K]>

The callback to remove.

void

Session.unsubscribe


upgradeTransport(transport): void

Defined in: packages/net-imap/src/imap/imap-client.ts:190

Replace the transport after a successful STARTTLS.

Buffered plaintext is discarded rather than carried across, since bytes sent before the handshake must never be read as part of the secured session.

Transport

The TLS transport wrapping the same connection.

void


wait<K>(event, options?): Promise<ImapClientEvents[K]>

Defined in: packages/async/src/events/event-dispatcher-map-base.ts:45

Wait for the next occurrence of a specific event, optionally matching a predicate.

This is a convenience method that subscribes to the dispatcher, waits for the next event that matches the predicate (if provided), and then unsubscribes automatically.

K extends "push" | keyof BaseSessionEvents

K

The event name to wait for.

EventDispatcherWaitOptions<ImapClientEvents[K]>

Optional settings including predicate and abort signal.

Promise<ImapClientEvents[K]>

A promise that resolves with the event arguments as an array.

Session.wait