https://github.com/sanand0/gmailmbox
Download mails from GMail into .mbox via API
https://github.com/sanand0/gmailmbox
tool
Last synced: 10 months ago
JSON representation
Download mails from GMail into .mbox via API
- Host: GitHub
- URL: https://github.com/sanand0/gmailmbox
- Owner: sanand0
- Created: 2024-08-31T13:42:00.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-19T03:58:40.000Z (almost 2 years ago)
- Last Synced: 2025-08-30T13:54:53.842Z (10 months ago)
- Topics: tool
- Language: Python
- Size: 2.93 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GMail Sync
This script lets me sync GMail to .mbox via the API (not IMAP), allowing me to analyze it offline.
## Usage
Clone this repository:
```bash
git clone https://github.com/sanand0/gmailmbox.git
cd gmailmbox
```
On Google Cloud Console, download `credentials.json` into `gmailmbox/`:
- [Create a new project](https://developers.google.com/workspace/guides/create-project)
- [Enable the Gmail API](https://support.google.com/googleapi/answer/6158841)
- [Create OAuth2 Client ID](https://developers.google.com/workspace/guides/create-credentials) for a Desktop app
- Download the JSON as `credentials.json`
Then install and run:
```bash
python gmailmbox.py --mbox emails.mbox --q "in:anywhere -in:spam -in:trash -invite"
# or
uv run gmailmbox.py --mbox emails.mbox --q "in:anywhere -in:spam -in:trash -invite"
# To refresh only new emails:
uv run gmailmbox.py --mbox emails.mbox --q "in:anywhere -in:spam -in:trash -invite" --update
```
This will sync all emails that match the query to the .mbox file.
Parameters:
- `--mbox`: Path to the .mbox file (default: "emails.mbox")
- `--q`: Gmail search query (default: "in:anywhere -in:spam -in:trash -invite")
- `--update`: Only update new emails (default: False)