๐ฅ๏ธ How to Use
This page walks through authenticating, ingesting, and parsing mail with the built-in Gmail support.
๐ Authentication
Create a credential store and an auth provider:
OAuth credentials come from the Google Cloud Console and are provided via file paths โ never hard-code tokens or secrets in source. Once authorized, the token is persisted by the credential store and refreshed automatically.
For distributed deployments, use Redis instead of pickle:
๐ฅ Ingesting messages
Build an adapter and a reader, then iterate:
Access the full model:
๐ Ingesting threads
MailIntakeThread aggregates its messages, participants, and last activity.
๐งช Parsers
Parsers normalize provider payloads and are used by the reader internally. They are also importable on their own:
extract_body(...)โ plain-text body extraction.parse_headers(...)โ structured header parsing.extract_sender(...)โ sender email/name extraction.normalize_subject(...)โ subject normalization for threading.
โ Checklist
- Provide OAuth credentials via a file path and a credential store.
- Build the
MailIntakeGoogleAuthprovider with the Gmail read-only scope. - Wrap the adapter in a
MailIntakeReader. - Consume
iter_messages/iter_threads; never call provider APIs directly.
๐ Read Next
- Overview โ layers and domain models.
- Extending Mail Intake โ custom providers and stores.