Skip to content

inbound-mail-foundation

Plugin host for inbound e-mail (inbox federation) — provider plugins (inbound-provider-imap, later M365 Graph / Gmail REST) register at the inboundMailProvider extension point with verify/fetch and optional oauth/watch (live push). The foundation owns three event-sourced streams (mail-account lifecycle, inbound-message with exactly-once ingest via deterministic aggregate ids, mail-thread rollup) and their projections read_mail_accounts/read_inbound_messages/read_mail_threads; PII fields are envelope-encrypted per tenant subject key before every append (crypto-shredding on tenant destroy). Wire createInboundMailConnectRoutes (OAuth connect + anonymous callback outside /api) and createInboundMailSupervisor (IDLE watch with backoff + reconciliation poll) in bin/server.ts. Consume inbound-mail-foundation:event:inbound-message-received from app features to attach business processes.

What this feature needs to run (Requires, top) and the write commands it provides (Provides, bottom).

flowchart TB
  n_inbound_mail_foundation["inbound-mail-foundation"]
  subgraph how_reqs["Requires"]
    n_tenant_lifecycle["tenant-lifecycle"]
  end
  subgraph how_provides["Provides"]
    n_cmd_inbound_mail_foundation_write_connect_account(["connect-account"])
    n_cmd_inbound_mail_foundation_write_disconnect_account(["disconnect-account"])
    n_cmd_inbound_mail_foundation_write_ingest_message(["ingest-message"])
    n_cmd_inbound_mail_foundation_write_update_account(["update-account"])
  end
  n_tenant_lifecycle --> n_inbound_mail_foundation
  n_inbound_mail_foundation --> n_cmd_inbound_mail_foundation_write_connect_account
  n_inbound_mail_foundation --> n_cmd_inbound_mail_foundation_write_disconnect_account
  n_inbound_mail_foundation --> n_cmd_inbound_mail_foundation_write_ingest_message
  n_inbound_mail_foundation --> n_cmd_inbound_mail_foundation_write_update_account

Provides — write commands this feature registers (dispatch them through the command bus):

  • Registers extension: tenantDatamail-account, tenantDatainbound-message, tenantDatamail-thread