// free agents / attachment-saver
📎 Email attachment saver
“Save every email attachment (invoices, PDFs, screenshots) into neat folders automatically.”
Free, no sign-up. MIT licence. Python standard library only, so there's nothing to pip install.
What it does
Scans your inbox over IMAP for emails with attachments and saves them as month/sender/filename. Filter by file type and sender, and duplicates are skipped by hash. Point it at a Google Drive, Dropbox or OneDrive synced folder and they end up in the cloud.
What you need
- Python 3.9+ (no extra packages) or self-hosted n8n
- IMAP access to your mailbox (app password for Gmail/Outlook)
- Optional: a cloud-synced folder on your computer
5-minute setup
Python
- Install Python 3.9+ and unzip the download.
- Try it with no accounts:
python3 attachment_saver.py --eml-dir sample_emails --dry-run - Copy
.env.exampleto.envand fill it in. - Run:
set -a; . ./.env; set +a; python3 attachment_saver.py(Windows steps in the README).
n8n (no code)
- Workflows, then Import from file, then
attachment-saver.n8n.json. - Follow the yellow “Read me” note (credentials or webhook).
- Test workflow, then switch it to Active.
Run it on a schedule
Every hour with cron:
0 * * * * cd /path/to/attachment-saver && set -a && . ./.env && set +a && python3 attachment_saver.py >> run.log 2>&1On Windows use Task Scheduler. With n8n, the Schedule node does it for you.
Settings
| Variable | What it does |
|---|---|
IMAP_HOST / IMAP_USER / IMAP_PASSWORD | Your mailbox |
SAVE_DIR | Where to save, default ./saved_attachments |
EXTENSIONS | Default pdf,png,jpg,jpeg,docx,xlsx,csv,zip |
FROM_CONTAINS | Optional sender filter, e.g. invoice,billing@,amazon |
DAYS | How far back to look, default 7 |
What we tested
- Ran on the included sample emails: PDF and PNG saved into month/sender folders, the .exe skipped, a resent duplicate invoice skipped.
- A second run saved nothing (hash index works).
- Fake IMAP test: read-only folder, BODY.PEEK fetch, sender filter.
- n8n workflow imported into a real n8n install. We didn't run it, because it needs your mailbox.
Honest limits
- Not tested against a real mailbox (needs your login).
- It never deletes or moves emails. That's on purpose.
- The n8n version writes to disk, so it needs self-hosted n8n. On n8n Cloud, swap the last node for a Google Drive or Dropbox upload.
Want one built for your task?
Describe it in one sentence. We build it, test it and hand it over, usually within 24h.