CLI tool to download Gmail messages matching configurable filters via OAuth2
Project description
📧 Download Gmail messages matching your filters to local files 📥
gmailstream is a Python CLI for downloading Gmail messages through OAuth2. It uses named profiles so each export can keep its own Gmail search query, credentials, mode, and target directory.
Use it to archive full .eml messages or save attachments from messages matched by Gmail search filters such as from:, has:attachment, after:, labels, and other Gmail query syntax.
Install
git clone https://github.com/tsilva/gmailstream.git
cd gmailstream
uv tool install . --force --no-cache
Create and authorize a profile, then run it:
gmailstream profiles init my-profile
gmailstream --profile my-profile
The init flow prompts for a Gmail filter, output directory, download mode, and a Google OAuth credentials.json file. See Creating OAuth Credentials for the Google Cloud setup.
Commands
uv sync # install development dependencies
uv tool install . --force --no-cache # install the CLI from this checkout
gmailstream --profile <profile> # download new matching messages
gmailstream --profile <profile> --from 2024-01-01 # limit by start date
gmailstream --profile <profile> --to 2024-12-31 # limit by end date
gmailstream --verbose --profile <profile> # enable debug logging
gmailstream --profile-dir /path --profile <name> # use a custom profiles directory
gmailstream profiles list # list profiles
gmailstream profiles init <name> # create and authenticate a profile
gmailstream profiles show <name> # print profile config
Notes
- Requires Python 3.12+ and
uv. - Profiles live in
~/.config/gmailstream/profiles/by default. Override this with--profile-dirorGMAIL_STREAMER_PROFILE_DIR. - Environment variables are loaded from
~/.config/gmailstream/.envwhen present. Existing shell environment variables take priority. - A profile can also be passed as a direct path to an existing profile directory.
- The legacy
gmailstream run <profile>command still works. - Each profile contains
config.yaml, user-suppliedcredentials.json, and auto-generatedtoken.json. mode: fullsavesmessage.eml, attachments, andmetadata.json.mode: attachments_onlysaves attachments plusmetadata.json.- Downloads are organized under the target directory as
YYYY-MM/YYYY-MM-DD - subject - shortid/. - Runs are incremental by default. Explicit
--fromor--todate ranges search that date range and skip files already present there. credentials.json,token.json, and downloaded email exports are sensitive local files. On POSIX systems, gmailstream writes them with user-only permissions, and credentials/tokens are ignored by git.
Architecture
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gmailstream-0.2.2.tar.gz.
File metadata
- Download URL: gmailstream-0.2.2.tar.gz
- Upload date:
- Size: 10.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
892ceed0973244c794bb1e231cf61b01935ff4511e5f851170282d860092c769
|
|
| MD5 |
0502afb9754970d8398425fe4ea1fd12
|
|
| BLAKE2b-256 |
f0151c0e3c9a0a97e90ca192a2bc3c8105fb1b10ca8567a1fcdae18c3c9e00db
|
Provenance
The following attestation bundles were made for gmailstream-0.2.2.tar.gz:
Publisher:
release.yml on tsilva/gmailstream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gmailstream-0.2.2.tar.gz -
Subject digest:
892ceed0973244c794bb1e231cf61b01935ff4511e5f851170282d860092c769 - Sigstore transparency entry: 1449513401
- Sigstore integration time:
-
Permalink:
tsilva/gmailstream@883b129c5580953c2d0ca7e488cc41effce1d358 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tsilva
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@883b129c5580953c2d0ca7e488cc41effce1d358 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file gmailstream-0.2.2-py3-none-any.whl.
File metadata
- Download URL: gmailstream-0.2.2-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4ea378c60f845c1b68a0c39b8e1ff385197d7685374adf7445ce692f2c3ce93
|
|
| MD5 |
1b0e594c18deb98d0a877a9647adfce5
|
|
| BLAKE2b-256 |
6d20646095a78eed596f52e54e3c591c34f1015e6e89659bb3b278b273bcca7b
|
Provenance
The following attestation bundles were made for gmailstream-0.2.2-py3-none-any.whl:
Publisher:
release.yml on tsilva/gmailstream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gmailstream-0.2.2-py3-none-any.whl -
Subject digest:
f4ea378c60f845c1b68a0c39b8e1ff385197d7685374adf7445ce692f2c3ce93 - Sigstore transparency entry: 1449513407
- Sigstore integration time:
-
Permalink:
tsilva/gmailstream@883b129c5580953c2d0ca7e488cc41effce1d358 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tsilva
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@883b129c5580953c2d0ca7e488cc41effce1d358 -
Trigger Event:
workflow_dispatch
-
Statement type: