Help us shape the future of Go! Take the 2026 Go Developer Survey

imap

package
v0.2.53 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: MPL-2.0 Imports: 40 Imported by: 0

Documentation

Overview

Package imap implements the chassis's IMAP head: a personality that serves a tenant's durable mailbox store (chassis/imap) to any IMAP4rev1 client — Apple Mail, Thunderbird, mutt — so a mail client becomes a UI over state that stacks project into the store with txco://imap/* ops.

The head is a GENERIC IMAP server: it knows no folder names and no product. Reads (LIST/SELECT/FETCH/SEARCH/IDLE) never touch the processor; they are served from the index columns cached at append and, for BODY[], from a deterministic render of the retained record. Writes that reach the store from an op are fanned out to selected sessions through a head-local hub (EXISTS / EXPUNGE / FETCH on Poll and IDLE).

Phase 0a scope (authentication first): LOGIN against the identity store (chassis/authn, shared with the DAV heads) behind per-IP and per-account LOGIN throttles, with a verified-login cache and the tenant admission check; NAMESPACE, LIST, STATUS, SELECT, FETCH, SEARCH, STORE (flags, local policy), POLL/IDLE, SUBSCRIBE. Mutating verbs (CREATE/DELETE/RENAME/APPEND/COPY/MOVE/EXPUNGE) answer NO [CANNOT] until the observe/answer lanes land.

IMAP is OFF by default. Both gates must be flipped:

  • `imap` must appear in `--personalities`
  • `--imap-listen-addrs` and/or `--imap-tls-addrs` must be non-empty

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBodyStructure

func DecodeBodyStructure(b []byte) (imap.BodyStructure, error)

DecodeBodyStructure restores a cached body structure.

func EncodeBodyStructure

func EncodeBodyStructure(bs imap.BodyStructure) ([]byte, error)

EncodeBodyStructure serialises a body structure for the row cache.

func SelfSignedPaths

func SelfSignedPaths(dbPath string) (certPath, keyPath string)

SelfSignedPaths derives the dev certificate + key file paths from the index path (`imap.db` → `imap-selfsigned.crt` / `.key` beside it).

func StoreVerbatim

func StoreVerbatim(ctx context.Context, fcas filecas.Store, ix blob.Index, tenant string, raw []byte, v *Verbatim, now time.Time) error

StoreVerbatim writes the message bytes and every part into the CAS, recording the tenant's ownership rows (ix may be nil: bytes only). Write order CAS → sha rows; the index row is the caller's AppendMessage.

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller owns the IMAP listeners and their go-imap servers. It satisfies the server's Start()/Stop() controller contract.

func NewController

func NewController(ctx context.Context, pu *processor.Unit, store *chimap.Store) *Controller

NewController constructs (but does not start) an IMAP controller. A nil store (imap personality not active) yields an inert controller whose Start is a no-op.

func (*Controller) SetAuth added in v0.2.31

func (c *Controller) SetAuth(r *authn.Resolver)

SetAuth hands the head the login resolver (chassis/authn).

func (*Controller) SetBlobIndex

func (c *Controller) SetBlobIndex(ix blob.Index)

SetBlobIndex wires the tenant sha-ownership index so message and part bytes a client APPENDs are owned by the account's tenant (readable through the blob plane by sha). Nil-safe.

func (*Controller) SetFileCAS

func (c *Controller) SetFileCAS(f filecas.Store)

SetFileCAS wires the content store BODY[] renders from. Nil-safe: without it, metadata still serves and BODY[] answers NO [UNAVAILABLE].

func (*Controller) SetTLSConfig

func (c *Controller) SetTLSConfig(t *tls.Config)

SetTLSConfig wires the certificate source for --imap-tls-addrs (implicit TLS) and for STARTTLS on the plaintext listeners.

func (*Controller) Start

func (c *Controller) Start()

Start binds the configured listeners and serves IMAP on each. The double-gate (personality string AND non-empty listen addrs) means an upgrade cannot acquire a new listener without explicit opt-in.

func (*Controller) Stop

func (c *Controller) Stop()

Stop closes the listeners and every connection. go-imap's Close is immediate (no drain); an IDLE client reconnects on its own.

type Ingested

type Ingested struct {
	Canonical []byte
	SHA256    string
	Rendered  []byte
	Message   chimap.Message
}

Ingested is a record turned into everything the store row and the CAS need: the canonical bytes (the CAS object, keyed by SHA256), the rendered RFC 5322 bytes (for the size + the cached structures — discarded after), and the row with ENVELOPE/BODYSTRUCTURE already cached.

func BuildRecordMessage

func BuildRecordMessage(rec *chimap.Record, objectKey, domain string, internal time.Time, flags []string) (Ingested, error)

BuildRecordMessage runs the formatter once over a record and caches what FETCH needs. objectKey/domain/internal are the RenderOptions and are stored on the row so the render is reproducible on every BODY[] fetch.

type Verbatim

type Verbatim struct {
	SHA256  string
	Message chimap.Message
	Facts   msgFacts
	// contains filtered or unexported fields
}

Verbatim is the result of parsing + measuring raw RFC 5322 bytes.

func ParseVerbatim

func ParseVerbatim(raw []byte, objectKey string, internal time.Time, flags []string) (*Verbatim, error)

ParseVerbatim parses raw bytes into a row + facts. objectKey may be "" (a client APPEND). Nothing is stored here; see StoreVerbatim.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL