This page walks through a simple installation and configuration of getmail.

It uses the Debian package manager, apt, as an example but the process should translate to any Linux variant.

Last checked/updated: August 2018.

(a) install getmail and create mail directories.

$ sudo apt install getmail4
$ mkdir ~/.getmail
$ mkdir ~/mail
$ mkdir ~/mail/cur
$ mkdir ~/mail/new
$ mkdir ~/mail/tmp

(b) create getmail configuration file ~/.getmail/getmailrc (a plain text file). You will need to fill in your email provider's information, including your username ( and password, so the program can fetch your emails. You also choose which folders to fetch, for instance just the inbox or also sent mail.

Example contents of ~/.getmail/getmailrc (fill in server if not gmail, mailboxes, USERNAME, and PASSWORD):

type = SimpleIMAPSSLRetriever
server =
mailboxes = ("[Gmail]/All Mail", )
username = USER
password = PASS

type = Maildir
path = ~/mail/

# only download *new* emails
read_all = false

# do not alter status of emails on server
delivered_to = false

# ditto
received = false

# do not delete emails on server
delete = false

# max downloaded each time; use 0 for no limit
max_messages_per_session = 0

message_log = ~/.getmail/log

(c) after creating the file, run $ chmod -R 700 ~/.getmail in order to prevent other users of the computer from reading this file. (But be aware of the privacy ramifications of storing your email password on your computer in plain text.

Done! Now, running getmail from the command line will connect to the server and download any new emails into ~/mail/tmp/. (Running it for the first time may take hours...)

(d) (bonus) you can use cron to have your linux system automatically run getmail every so often.

$ sudo apt install cron

For example, to connect every 10 minutes, simply run

$ crontab -e

to open the the crontab file for editing, and insert the line

*/10 * * * * getmail

which tells cron to run getmail once every 10 minutes of every hour of every day of every month of every year.