Add multi-account email support with IMAP fallback#1
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Search several mailboxes in one run. Accounts are listed under
email_accountsin config.yml and served through aMailProviderabstraction:-aflag): Google-hosted addresses on any domainimap.password_env), never configNo
email_accountsblock means the previous behavior exactly: gog's default account, no extra setup.Behavior
accountfield and every operation (CLI fetch/archive, MCP tools) routes through the originating provider. The mailbox MCP tools take an optionalaccountparam, only needed when several accounts are configured. Drafts always go through a Google account._safe_idargument-injection validation is preserved on all gog calls.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 awarningslist.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.