Saves all your mailboxes from IMAP account into .mbox files. It saves each mailbox into separate .mbox file in the given folder. It uses SSL connection to connect to your IMAP server. It ignores some special mailboxes: Archive, Junk, Trash, Sent, and Drafts.
During backup process emails are synced from IMAP (mail server) to MBOX (local file).
- Create Python virtual env:
python -m venv env
- Activate virtual environment
. ./env/bin/activate
- Install dependencies
pip install -r requirements.txt
- Create .env file with the following content:
EMAIL = "<your email>"
IMAP_SERVER = "<your imap server hostname>"
LOCAL_MBOX_FOLDER = "<local folder name to store all emails/mailboxes>"
python backup_email.py
Script will ask for the password for your email account.
Enjoy!