About 2 years ago I wrote myself a small program to back up my e-mails to my local computer. It’s a very simple commandline tool that connects to a IMAP server, downloads all messages and stores them in EML format. For a long time I did not plan to publish the program, but only wanted to run it every few days myself. In the last months I have also told some friends and colleagues about it and encountered a lot of interest. For this reason I cleaned up the source code and published it on Github.

Screenshot of the command line interface

Why use eml?

EML is a simple text format which is supported by many e-mail programs. On Windows 10, no additional software needs to be installed to view EML files. The files also contain all header information and attachments in a single file - no information is lost. Due to it’s nature as a text format most operating systems know how to read and index the content of these files. Therefore you can just use the Explorer to search inside your local mails. Thus the export as EML has some advantages over Outlook or Thunderbird data files, which are hard to restore or exchange - and can only be converted with a lot of manual effort when switching the mail client.

Usage

Execute either mailbackup.sh (MacOS / Linux) oder mailbackup.ps1 (Windows). Basic usage works like this

./mailbackup.ps1 -username <USERNAME> -password <PASSWORD>

There are several parameters that you can use to change the default behaviour: