Need to back up your email account or migrate to another platform? My new Python tool downloads all your IMAP emails and converts them into mbox format β perfect for archiving, importing to other email clients, or safe long-term storage.
π‘ What It Does
This tool connects to your IMAP server (like Gmail, Outlook, or your custom domain), grabs all your messages β even from large 100GB+ mailboxes β and saves them as .eml
files. Then, with a single flag, it can convert them into an .mbox
file, the standard format supported by email clients like Thunderbird, Apple Mail, and many more.
π₯ Features
-
β Works with any IMAP server
-
π Select folders or download everything
-
βοΈ Batch processing for big inboxes
-
π§ Metadata tracking to skip already-downloaded messages
-
π¦ Converts to
.mbox
for import/export -
π Secure password input
-
π Lightweight and Pythonic
π Quick Start
π§± Requirements
Make sure Python 3.6+ is installed.
git clone https://github.com/yourusername/imaptombox.git cd imaptombox pip install -r requirements.txt
All other dependencies are built into Python.
π οΈ How To Use
π₯ Download and Convert in One Step
python3 imaptombox.py --host imap.example.com --username [email protected] --convert
πΎ Just Download Emails
python3 imaptombox.py --host imap.example.com --username [email protected]
π Convert Only (Skip Download)
python3 imaptombox.py --convert --skip-download --output-dir emails/
π§ Command-Line Options
Flag | Description |
---|---|
--host |
Your IMAP server hostname |
--username |
Your email address |
--port |
Server port (default: 993) |
--no-ssl |
Use plain IMAP (not secure) |
--output-dir |
Where emails are saved |
--folders |
Download specific folders |
--inbox-only |
Download only INBOX |
--max-emails |
Limit emails per folder |
--download-all |
Redownload everything |
--start-message |
Start from specific message ID |
--batch-size |
Emails per batch (default: 1000) |
--convert |
Convert to mbox format |
--convert-folder |
Convert only a specific folder |
--mbox-file |
Set custom output filename |
--skip-download |
Skip download and only convert |
--debug |
Enable debug logging |
π Output Structure
π Dependencies
This script uses only a few extra Python packages:
email-validator>=1.1.3 python-dateutil>=2.8.2 tqdm>=4.62.3
Install them easily with:
pip install -r requirements.txt
π¨βπ» About the Author
This tool was created by Denis (BeforeMyCompileFails) in 2025 (yes that’s me, so this is a shameless selfpost!).
Itβs open-source, scalable, and designed to handle inboxes of any size.