Add --verbose/-VERBOSE option to print sender and subject for each archived message; bump version to 0.2.0 across pyproject.toml, man page, and metainfo XML; document systemd automated archiving in README; add debian:forky to Jenkinsfile build matrix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| data | ||
| debian | ||
| mailbox_cleaner | ||
| man | ||
| .gitignore | ||
| pyproject.toml | ||
| README.md | ||
MailBoxCleaner
Move old IMAP messages to Thunderbird Local Folders (mbox archive) to free server storage quota.
Usage
mailbox-cleaner --host imap.example.com --user you@example.com --password secret \
[--port 993] [--folder INBOX] [--older-than 365] \
[--archive-name Archive] [--thunderbird-profile PATH] \
[--batch-size 200] [--dry-run] \
[--deploy [--interval CALENDAR]]
All options can also be set via environment variables:
| Option | Env var | Default |
|---|---|---|
--host |
IMAP_HOST |
(required) |
--port |
IMAP_PORT |
993 |
--user |
IMAP_USER |
(required) |
--password |
IMAP_PASSWORD |
(required) |
--folder |
IMAP_FOLDER |
INBOX |
--older-than |
IMAP_OLDER_THAN |
365 |
--archive-name |
ARCHIVE_NAME |
Archive |
--thunderbird-profile |
THUNDERBIRD_PROFILE |
(auto-detected) |
--batch-size |
BATCH_SIZE |
200 |
--verbose |
VERBOSE |
(off) |
Use --dry-run to preview which messages would be archived without making any changes.
Use --verbose to print the sender address and subject of each message as it is archived.
What it does
- Connects to IMAP over SSL
- Searches the specified folder for messages older than
--older-thandays - Downloads up to
--batch-sizemessages and appends them to an mbox file inside Thunderbird's Local Folders - Marks the originals as deleted and expunges them from the IMAP server
- Prints a summary
Run again to process the next batch. After archiving, restart Thunderbird (or right-click the folder → Repair Folder) to rebuild the index.
Automated archiving with systemd
Use --deploy to install a systemd user service and timer that run mailbox-cleaner automatically:
mailbox-cleaner --host imap.example.com --user you@example.com --password secret \
--deploy --interval "Mon *-*-* 02:00:00"
This writes credentials to ~/.config/mailbox-cleaner.env (mode 600) and installs:
~/.config/systemd/user/mailbox-cleaner.service~/.config/systemd/user/mailbox-cleaner.timer
The timer is enabled and started immediately. Check its status with:
systemctl --user list-timers mailbox-cleaner.timer
The --interval option accepts any systemd OnCalendar expression (default: daily). Examples: weekly, hourly, "Mon *-*-* 02:00:00".
Installation
sudo dpkg -i mailbox-cleaner_*.deb
Building the Debian package
dpkg-buildpackage -us -uc -b