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

pgsql
emails/
β”œβ”€β”€ INBOX/
β”‚ β”œβ”€β”€ 001_Hello_World.eml
β”œβ”€β”€ Sent/
β”‚ β”œβ”€β”€ 002_Sent_Message.eml
β”œβ”€β”€ metadata.json
└── archive.mbox

πŸ“œ 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.