--- name: gmail-statement-fetcher description: Automatically download bank/financial statement PDFs from Gmail via IMAP or OAuth. Config-driven bank rules, UID dedup, ZIP extraction, PDF decryption. metadata: {"openclaw":{"emoji":"📬","version":"1.0.2","homepage":"https://github.com/notoriouslab/gmail-statement-fetcher","requires":{"bins":["python3"],"env_via_dotenv":["GMAIL_USER","GMAIL_APP_PASSWORD"]}}} --- # gmail-statement-fetcher Automatically download bank/financial statement PDFs from Gmail. ## When to use - User asks to download bank statements from Gmail - User wants to set up automated statement fetching - User asks to fetch encrypted/password-protected PDF statements - User wants to extract PDFs from ZIP attachments in email ## Credential setup Credentials MUST be loaded from environment or secrets file — **NEVER inline passwords in shell commands**. ```bash # Option A: .env file in the project directory (recommended) # Create {baseDir}/.env with: # GMAIL_USER=user@gmail.com # GMAIL_APP_PASSWORD=your-app-password # The fetcher loads .env automatically via python-dotenv. # Option B: export from secrets file export GMAIL_USER=$(python3 -c "import json; print(json.load(open('$HOME/.paiop_secrets.json'))['gmail_user'])") export GMAIL_APP_PASSWORD=$(python3 -c "import json; print(json.load(open('$HOME/.paiop_secrets.json'))['gmail_app_password'])") ``` Bank PDF/ZIP passwords follow the same pattern — use env vars or .env, never inline: ```bash # In .env: # SINOPAC_PDF_PASSWORD=xxx # CTBC_ZIP_PASSWORD=xxx ``` ## Commands ### Fetch statements (IMAP mode, default) ```bash python3 {baseDir}/fetcher.py ``` ### Dry run — preview matches without downloading ```bash python3 {baseDir}/fetcher.py --dry-run --verbose ``` ### Custom config and output directory ```bash python3 {baseDir}/fetcher.py --config "{{config_path}}" --output-dir "{{output_dir}}" ``` ### OAuth mode ```bash AUTH_METHOD=oauth python3 {baseDir}/fetcher.py ``` ## Options | Flag | Description | |---|---| | `--config` | Path to config JSON (default: `