Backup emails with getmail

 Installing

yum install getmail

Creating directory structure

$ mkdir ~/.getmail
$ touch ~/.getmail/getmailrc
$ chmod 700 ~/.getmail

Create where files will be backed up to

$ mkdir -p ~/mailbackup/mail
$ cd ~/mailbackup/mail
$ mkdir cur new tmp

 Config file

Imap

[retriever]
type = SimpleIMAPSSLRetriever
server = imap.xxx.co.uk
username = martin@xxx.co.uk
password = xx
port = 993
mailboxes = ALL

[destination]
type = Maildir
path = ~/nrmartin/

[options]
# retrieve only new messages
# if set to true it will re-download ALL messages every time!
read_all = false

verbose = 2
message_log = ~/.getmail/nrmartinlog

mailboxes = ALL
# do not alter messages
delivered_to = false
received = false

Mutliple config fils

getmail --rcfile getmail1rc

getmail --rcfile getmail1rc --rcfile getmail2rc

A bash script: `

!/bin/sh

set -e cd /path/to/my-rc-directory rcfiles="" for file in rc-* ; do rcfiles="$rcfiles --rcfile $file" done exec /path/to/getmail $rcfiles $@ `

More info

http://pyropus.ca/software/getmail/faq.html https://wiki.archlinux.org/index.php/Backup_Gmail_with_getmail https://www.linode.com/docs/email/clients/retrieve-email-using-getmail/

See also

[offlineimap]