Getmail

This page describes getmail, a command-line tool for retrieving mails.

Installation

$ aptitude isntall getmail4

Example configuration: GMail backup

Create a ~/.getmail/gmail file:

[retriever]
type = SimpleIMAPSSLRetriever
server = imap.googlemail.com
username = foo@gmail.com
password = <your-password>
mailboxes = ("[Gmail]/All Mail")
port = 993

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

[options]
received = false
delivered_to = false
read_all = false
verbose = 2
message_log = ~/.getmail/gmail.log
message_log_verbose = true

Then run

$ getmail -r gmail

The initial run will fetch all mail. Subsequent executions will only fetch new mails.

Example configuration: deliver to dovecot

This examples fetches all mail from GMail and delivers it to a local Dovecot IMAP server.

Create a ~/.getmail/deliver file:

[retriever]
type = SimpleIMAPSSLRetriever
server = imap.googlemail.com
username = foo@gmail.com
password = <your-password>
mailboxes = ("[Gmail]/All Mail",)
port = 993

[destination]
type = MDA_external
path = /usr/lib/dovecot/deliver
arguments = ("-e", "-f", "%(sender)", "-d", "foo@example.com")
user = vmail
group = vmail

[options]
received = false
delivered_to = false
read_all = false
verbose = 2
message_log = deliver.log
message_log_verbose = true

The executor requires permission to invoke the deliver program as vmail user, so you may run it with sudo:

$ sudo getmail -g /home/<user>/.getmail/ -r deliver

Sources: