{"id":50772268,"url":"https://github.com/cedrichan/mailclean-py","last_synced_at":"2026-06-11T20:01:54.033Z","repository":{"id":345635643,"uuid":"1133066973","full_name":"cedrichan/mailclean-py","owner":"cedrichan","description":"Clean out large attachements from gmail messages.","archived":false,"fork":false,"pushed_at":"2026-03-20T05:43:36.000Z","size":73,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-20T16:21:40.905Z","etag":null,"topics":["attachments","email","gmail"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cedrichan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-12T20:50:13.000Z","updated_at":"2026-03-20T05:43:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cedrichan/mailclean-py","commit_stats":null,"previous_names":["cedrichan/mailclean-py"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/cedrichan/mailclean-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrichan%2Fmailclean-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrichan%2Fmailclean-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrichan%2Fmailclean-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrichan%2Fmailclean-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cedrichan","download_url":"https://codeload.github.com/cedrichan/mailclean-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedrichan%2Fmailclean-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34215254,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["attachments","email","gmail"],"created_at":"2026-06-11T20:01:53.429Z","updated_at":"2026-06-11T20:01:54.027Z","avatar_url":"https://github.com/cedrichan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mailclean-py\n\nA suite of Python scripts designed to help you declutter your Gmail inbox by identifying large emails, saving their attachments locally, and replacing them with lightweight, attachment-free versions.\n\nMostly vibe coded and tested on my own actual inbox. Use at your own risk.\n\n## Project Structure\n\n*   `large_attachments.py`: Finds large emails and marks them for processing.\n*   `strip_attachments.py`: Downloads attachments locally and creates \"cleaned\" versions of the emails in Gmail.\n*   `remove_originals.py`: Safely removes the original large emails after you've verified the cleanup.\n*   `oneshot.py`: A single command that performs all three steps (tag, strip, and remove) automatically.\n\n---\n\n## Prerequisites\n\n1.  **Google Cloud Project**: You need a Google Cloud project with the **Gmail API** enabled.\n2.  **Credentials**: Download your `credentials.json` from the Google Cloud Console and place it in the project root.\n3.  **Python 3.13+**: This project uses modern Python features.\n4.  **Package Manager**: This project uses `uv`. Install it via [astral.sh/uv](https://astral.sh/uv).\n\n### Installation\n\nInstall the required dependencies using `uv`:\n\n```shell script\nuv sync\n```\n\n\n---\n\n## Usage Workflow\n\nThe cleanup process is designed in three distinct steps to ensure no data is lost.\n\n### Step 1: Identify and Label Large Emails\nRun `large_attachments.py` to scan your inbox. By default, it looks for emails larger than 20MB and applies a `PRE_CLEANUP` label to them.\n\n```shell script\n# Search for emails \u003e 20MB (default)\nuv run mailclean/large_attachments.py\n\n# Or specify a custom threshold in bytes\nuv run mailclean/large_attachments.py --size 10000000\n```\n\n\n### Step 2: Strip and Save Attachments\nRun `strip_attachments.py` to process the emails marked `PRE_CLEANUP`.\n- It downloads attachments to a local directory.\n- It creates a `.url` shortcut in the local folder pointing to the new email.\n- It creates a \"cleaned\" copy of the email in Gmail (body only) with a `POST_CLEANUP` label.\n\n```shell script\nuv run mailclean/strip_attachments.py --download_dir ./my_attachments_folder\n```\n\n\n### Step 3: Remove Original Emails\nOnce you are satisfied that your attachments are safe and the cleaned emails are correct, run `remove_originals.py` to move the original large emails to the Trash.\n\n```shell script\n# First, perform a dry run to see what would be deleted\nuv run mailclean/remove_originals.py --dry-run\n\n# Perform the actual deletion (moves to Trash)\nuv run mailclean/remove_originals.py\n```\n\n\n---\n\n## One-Shot Cleanup\n\nIf you want to perform all steps at once without manual verification between them, use `oneshot.py`. This script will:\n1. Find and label large emails.\n2. Download attachments and create cleaned versions.\n3. Move the original emails to the Trash.\n\n```shell script\n# Run full cleanup for emails \u003e 20MB\nuv run mailclean/oneshot.py --download_dir ./my_attachments_folder\n\n# Specify custom size in bytes\nuv run mailclean/oneshot.py --download_dir ./my_attachments_folder --size 10000000\n```\n\n\n---\n\n## Labels Used\n- **PRE_CLEANUP**: Applied to original large emails found by the scanner.\n- **POST_CLEANUP**: Applied to the new, attachment-free versions of your emails.\n\n## Safety Features\n- **Trash instead of Delete**: `remove_originals.py` moves files to the Gmail Trash rather than permanently deleting them, giving you a 30-day window to recover them.\n- **Safety Checks**: The removal script checks for the presence of the `POST_CLEANUP` label on messages to prevent accidental deletion of already cleaned content.\n\n---\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedrichan%2Fmailclean-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcedrichan%2Fmailclean-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedrichan%2Fmailclean-py/lists"}