himalaya
repository·master·Indexed 25 days ago
https://github.com/pimalaya/himalayaA CLI tool to manage emails across multiple protocols and providers, including IMAP, SMTP, JMAP, Gmail REST API, and Microsoft Graph. It provides a unified interface for managing mailboxes, messages, and attachments, featuring a configuration wizard, support for OAuth 2.0 via token brokers, and backend-agnostic commands for searching and reading mail.
What's inside himalaya
- Some JMAP providers (such as Fastmail) serve blob downloads from a different host than the primary API endpoint. The Himalaya JMAP client handles this by opening a fresh authenticated connection to the download host instead of following a redirect on the API socket.
Understand the Cairn command structure
masterThe Cairn command tree is organized into three distinct groups:
- Shared API: Cross-protocol commands (
mailbox,envelope,flag,message,attachment) that behave consistently regardless of the backend. These run over anEmailClientand select a backend based on the--backendflag (preferring local over network backends). - Protocol-specific APIs: Commands specific to a backend (
imap,jmap,gmail,msgraph,maildir,m2dir,smtp). These ignore the--backendflag and interact directly with the specific protocol's client. - Meta commands: Commands for configuration and utility (
account,completion,manual).
- Shared API: Cross-protocol commands (
Understand the Himalaya Search Specification
masterHimalaya's shared envelope search uses a single, backend-agnostic query language. This language is parsed once and then translated into the native search syntax of the specific backend being used. The query structure consists of a filter tree and a sort list. The parser is built usingchumskyand provides error reporting viaariadnethrough the CLI.Time-bounded IMAP Discovery
masterIMAP discovery processes are now time-bounded to prevent stalling. If an endpoint is unreachable, the Wizard will not wait for the full operating-system connect timeout. Each authentication mechanism runs on its own thread, and any mechanism still running at the discovery deadline is abandoned.Locate testing reports and QA documentation in Cairn
masterTesting reports and operational QA documentation have been migrated from the
docs/testing/directory to the Cairn specification directory.- Testing Reports & Index: Located at
cairn/spec/testing/. The index file iscairn/spec/testing/README.mdand includes thecapability: testingspec frontmatter. - Test Plans: The
provider-test-plan.mdis located withincairn/spec/testing/.
Use this directory to access the current truth regarding project coverage and the testing capability implementation.
- Testing Reports & Index: Located at
Run the interactive configuration wizard
masterTo start the interactive configuration wizard, run the
himalayacommand without any subcommands. If a command is run and no configuration is found, the wizard will also be proposed.Important Behavior:
- The wizard discovers an account and prints a ready-to-save TOML fragment to
stdout. - It writes nothing to disk automatically.
- Prompts are rendered on
stderr, allowing you to redirect the generated configuration directly into a file using standard shell redirection.
- The wizard discovers an account and prints a ready-to-save TOML fragment to
Use the discovered-account wizard for service setup
masterThe account discovery wizard has been updated to a two-step selection process:
- Service Selection: The discovery list now displays one entry per service.
- Authentication Selection: A second service-specific prompt allows you to choose the authentication method:
- For IMAP + SMTP: Choose the appropriate SASL mechanism.
- For JMAP: Choose the HTTP scheme.
- For OAuth: This is now integrated into the API-token credential prompt rather than being a separate, non-functional option.
Note on IMAP/SMTP configuration: During the IMAP + SMTP flow, the wizard tests each protocol individually during configuration and will prompt you to decide if SMTP should share the same credentials as IMAP.
Configure authentication and OAuth in the wizard
masterThe wizard follows a service-first, then authentication-second flow:
- Service Selection: The discovery list shows one entry per reachable service (e.g., IMAP + SMTP, JMAP, Gmail, Microsoft Graph).
- Authentication Selection: After picking a service, you choose an authentication method. For IMAP, the wizard probes the server's live
CAPABILITYto offer only supported SASL mechanisms (preferring modern ones over legacyLOGIN). - OAuth Integration: Himalaya does not perform OAuth 2.0 grants. Instead, OAuth is integrated into the API-token credential prompt. It offers:
- OS keyrings: For tokens you have already generated.
- OAuth token brokers: Such as
Ortie,pizauth, oroama(these appear only if the service advertises OAuth support).
Handle OAuth 2.0 via token brokers
masterHimalaya v2 does not include built-in OAuth flows. To use OAuth 2.0, use a token broker (like
pimalaya/ortie) to obtain an access token, then configure Himalaya to retrieve that token via acommandthat prints it to stdout.- For JMAP: Point
jmap.auth.bearer.token.commandto the broker. - For IMAP/SMTP: Route the bearer through a SASL mechanism that consumes a command-sourced password.
- For JMAP: Point
Verify IMAP and SMTP credentials
masterThe authentication flow for IMAP and SMTP follows a specific testing sequence:
- Test the IMAP connection first.
- Prompt the user to decide if SMTP should reuse the same credentials.
- If different credentials are required, re-run the SASL prompt for a distinct set.
- Test the SMTP connection last.
Note: If a backend performs inline validation, the final account test is skipped.
Manage IMAP special-use aliases
masterCurrently, automatic IMAP special-use alias discovery is limited to theINBOXreserved folder. Discovery for other folders likeSent,Drafts,Trash,Junk, orArchiveis not yet supported viaLIST RETURN (SPECIAL-USE). You must configure these other IMAP aliases manually in your settings.Provide input to the configuration wizard
masterThe wizard accepts a single input prompt that determines the flow. You can provide one of the following:
- An email address or bare domain: Triggers parallel discovery via
io-pim-discovery. - A
scheme://server URL: Configures the service manually via the provided URL. - A local folder path: Configures a local Maildir or m2dir folder.
Note: Discovery is time-bounded. If an endpoint is unreachable, the wizard will abandon that specific mechanism after a short deadline and fall back to manual entry to prevent stalling.
- An email address or bare domain: Triggers parallel discovery via