Skip to content

Add multi-account email support with IMAP fallback#1

Merged
Unbelieva merged 1 commit into
mainfrom
Unbelieva/port-feature-to-clean-fetch
Jun 12, 2026
Merged

Add multi-account email support with IMAP fallback#1
Unbelieva merged 1 commit into
mainfrom
Unbelieva/port-feature-to-clean-fetch

Conversation

@Unbelieva

Copy link
Copy Markdown
Member

What

Search several mailboxes in one run. Accounts are listed under email_accounts in config.yml and served through a MailProvider abstraction:

  • GmailProvider (gog CLI, -a flag): Google-hosted addresses on any domain
  • ImapProvider (imap-tools): any other mailbox; passwords come from env vars (imap.password_env), never config

No email_accounts block means the previous behavior exactly: gog's default account, no extra setup.

Behavior

  • Search fans out across all accounts concurrently; one failing account is reported and skipped instead of aborting the run.
  • Message/thread/attachment ids are account-scoped. Records carry an account field and every operation (CLI fetch/archive, MCP tools) routes through the originating provider. The mailbox MCP tools take an optional account param, only needed when several accounts are configured. Drafts always go through a Google account.
  • Staged attachment downloads are namespaced by account as well as message id (IMAP UIDs are small integers that repeat across mailboxes), on top of the existing basename sanitization. _safe_id argument-injection validation is preserved on all gog calls.
  • Onboarding/health_check: per-account gog auth via gog auth list --json, MX-lookup warning when a gmail-configured domain is not Google-hosted, a note on the External OAuth client requirement for multi-domain setups, and an IMAP login test. The report now includes a warnings list.

Tests

55 pass (was 29): provider command construction and account targeting, staging namespacing/sanitization for both providers, config parsing, multi-account search merging and failure isolation, MCP account resolution, IMAP normalization. ruff check/format clean.

Mailboxes are configured under email_accounts in config.yml and served
through a MailProvider abstraction: GmailProvider (gog CLI, -a flag) for
Google-hosted addresses on any domain, ImapProvider (imap-tools) for
everything else. Search fans out across all accounts concurrently; one
failing account no longer aborts the run.

Message, thread, and attachment ids are account-scoped, so records carry
an account field and every operation routes through the originating
provider: the CLI fetch/archive flow and the MCP mailbox tools, which
take an optional account parameter (needed only when several accounts
are configured). Drafts always go through a Google account. The Gmail
id validation (_safe_id) and staging hardening are preserved, and staged
attachments are now namespaced by account as well as message id, since
IMAP UIDs are small integers that repeat across mailboxes.

Onboarding and health_check now validate per-account gog auth (gog auth
list --json), warn when a gmail-configured domain is not Google-hosted
(MX lookup), note the External OAuth client requirement for multi-domain
setups, and login-test IMAP accounts. IMAP passwords come from env vars,
never config.yml.
@Unbelieva
Unbelieva merged commit 0dc1e33 into main Jun 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant