Getmail

Introduction
getmail is a mail retriever designed to allow you to get your mail from one or more mail accounts on various mail servers to your local machine for reading with a minimum of fuss. It is designed to be secure, flexible, reliable, and easy-to-use.

Install
We need, so install it with:

Pre-Configuration
We will save all getmail related files in.

If you have only one mail account, we will create the file.

If you have multiple mail accounts, we will need to create a configuration file for each of them.

Configuration
Now that you have created all getmail configuration files, we can begin to setup the mail accounts. A configuration file consists of three sections: retriever, destination and options. The section retriever contains your connection data to your mail provider. The destination section says what to happen with new mails like saving to disk. options contain settings such as being verbose, only check new mails, delete mails after having fetched them, logging messages to syslog, etc.

IMAP
You can receive your Gmail mails using getmail. IMAP makes it even possible to receive your Spam mails. That's useful if you want to use your own spam-filter as the Gmail spam-filters recognize many ham-mails as spam. Note that you can only receive your spam-mails using IMAP. Gmail does not have an option to allow you to receive your spam-mails using POP3. If you have signed up your Gmail account from a German IP address, you need to substitute [Gmail]/Spam by [Google Mail]/Spam in the mailboxes variable (Google does not hold the trademark Gmail in Germany, it is called there Google Mail instead. See Wikipedia for futher information.). [retriever] type = SimpleIMAPSSLRetriever server = imap.gmail.com username = password = mailboxes = ("INBOX", "[Google Mail]/Spam")

Use SimpleIMAPRetriever for the variable type if your server does not support SSL encryption.

POP3
[retriever] type = SimplePOP3SSLRetriever server = pop.gmx.net port = 110 username = password =

Use SimplePOP3Retriever for the variable type if your server does not support SSL encryption.

Destination
getmail supports to directly save the files to the file system and to pipe it to other applications. The last one might be interesting for you if you want to check the incoming mails for spam or to move mails to subfolders according to their subjects, senders, etc. This can be done using the application procmail.

maildir
If you do not want to virus-check, auto-move or spam-check your incoming mails, you can use this method. [destination] type = Maildir path = ~/.maildir/

If there is a new e-mail, it will be now in ~/.maildir mailbox and automatically made accessible via IMAP if desired.

procmail
[destination] type = MDA_external path = /usr/bin/procmail arguments = ("-f", "%(sender)")

maildrop
[destination] type = MDA_external path = /usr/bin/maildrop unixfrom = true

SpamAssassin
[filter] type = Filter_external path = /usr/bin/spamc

Deleting Mails After Fetching Them
This can be either done globally using the getmail option -d or for every getmailrc-file manually (see next section for how to use the getmail-command) by setting delete to true in the section options: [options] delete = true

Enable verbosity
[options] verbose = 1

Log messages to syslog instead of stdout
[options] message_log_syslog = true

Specify log file
Instead of logging to syslog, you can specify the path to your own log file. [options] message_log = ~/.getmail/log

Single-account setup
You can simply run getmail like this:

Multiple-account setup
You need to pass all files to the getmail command:

Retrieving your mails automatically with cron
Once you are confident with your getmail setup, you can automate the fetching using a cron job. Open up your crontab with: Add the following: