defineMailIntegration reads an IMAP mailbox into three synced tables: one for
what the mailbox reports about each message, one for the message contents, and
one for folder membership.
bijection/mailbox.ts
bijection/schema.ts
provider is "imap". every optionally sets the sync interval and defaults
to { minutes: 1 }.
The three collections
Every record carries amessage_key, the message’s identity. It doesn’t depend
on which folders the message is in.
messages: what the mailbox reports about a message:provider_id, and where knownthread_id,received_atandarrival_key.contents: what is decoded from the message itself:subject,message_id,sent_at, thefrom,toandccaddresses,body_textandbody_html, the raw message as a stored file inraw_mime, andattachments, each a stored file with itsname,media_type,sizeandsha256.content_statusispending,completeorunavailable.memberships: which folder a message is in (folder_key) and itsflags.
raw_mime and each attachment’s file are
file storage IDs.
The first sync establishes the mailbox as it is. It does not report every
existing message as a new arrival.
Connecting
The connection’s private configuration names the IMAP server, the login and the folders to read:mailbox-connection.json
securityisimplicit_tlsfor a TLS port, orstart_tlsto upgrade a plaintext connection.folderslists one to eight distinct folders.
--base-url:
Gaps and repair
bijection integration source-status <source> reports, per mailbox, how many
messages are waiting for content and how many metadata and content reads
failed. To retry the failed reads, pass the mail revision that
source-status reports: