Download an offline copy of an IMAP mail account

  1. Download offlineimap
  2. Create ~/.offlineimaprc

    [general]
    accounts = Me
    
    [Account Me] # <-- account identifier
    localrepository = Local
    remoterepository = Remote
    
    [Repository Local]
    type = Maildir # <-- Download "format"/"structure"
    localfolders = ~/archives/REMOVED # <-- Location
    
    [Repository Remote]
    type = IMAP
    remotehost = imap.REMOVED.com <-- IMAP Server
    remoteuser = REMOVED@REMOVED.com <-- Complete email address!!!
    ssl = yes
    sslcacertfile = /etc/ca-certificates/extracted/ca-bundle.trust.crt
    
  3. Run offlineimap
  4. Read the folder in the format you choosen

For example I selected maildir1 format. You can choose any program to easily read from that format or just backup/store in that format. It’s a very good way of storing your emails as it keeps all the “metadata” and not just the contents.

You can also keep this command in a cron job (in that case, you’ll have to find a way to autofill the password).

Footnotes: