Have you ever needed to access email stored on a server other than your own? Getmail makes it easy to retrieve messages from remote servers.
This is a guide for setting up the popular getmail email retrieval program. After you work through it, you’ll be able to retrieve your email from all sorts of different mail servers.
Table of Contents
What is getmail/getmailrc?
Getmail is designed to replace other mail retrievers such as fetchmail. It supports multiple POP3 servers, all POP3 servers on a given host, all POP3 servers at GMX, multiple IMAP servers, all IMAP servers on a given host, and multiple SMTP servers. Multiple accounts per server are also supported.
Getmailrc is the configuration file for getmail. It should be placed in ~/.getmail/getmailrc. The format of this file is very simple, it consists of commands and parameters separated by whitespace (spaces or tabs). Comments begin with a pound sign.
Getmail supports all common mail retrieval methods and can run in daemon mode to check for new mail at regular intervals.
Getmailrc is a configuration file for getmail. It allows you to specify many of the options that getmail accepts on the command line. The default location for getmail-rc is /usr/local/etc/getmail/.
Features of Getmail
The following list summarizes some of getmail’s features:
- Support for POP3, IMAP4, SMTP and local Maildirs.
- Supports multiple accounts on multiple servers at the same time.
- SSL/TLS support (IMAPS/POP3S).
- Authentication via SASL (PLAIN, LOGIN, CRAM-MD5).
- SSL/TLS support for IMAP4 connections (with STARTTLS).
- Filtering of messages based on various criteria (message headers; attachment names; size).
How do I install and configure the getmail client?
Getmail is a free, open source email checking and retrieval program for Linux and Unix. It is licensed under the GNU General Public License (GPL) version 2 or later.
The getmail package includes a small daemon called getmail which, when run periodically by cron, checks POP/IMAP mailboxes at the configured host(s) for new mail and passes it on to a local delivery agent (such as msmtp).
Getmail’s configuration file is /etc/getmail/getmailrc , which contains all of your account information and other settings.
How do I configure a getmailrc file?
The getmailrc file is a simple text file that contains parameters for getmail to run. The getmailrc file is used by the program getmail, which in turn uses popfile or procmail to send and receive mail.
By default, getmail looks for a getmailrc file in your home directory. If you have more than one user account and want to use a different rc file for each account, you can specify the location of the rc file by using the rcfile option on the command line when you run getmail.
If you only need one rc file, name it getmailrc in that directory (or whatever name you choose), and you won’t need to supply any commandline options to run getmail.
How do I start using getmail?
Install the getmail package from your operating system’s package manager. For example, if you use Debian or Ubuntu, run apt-get install getmail .
Get a POP3 server. Many ISPs provide one for their customers, but if yours doesn’t, you can use any of the many free services that offer POP3 access. You’ll need to register an account and provide the server’s address and port number.
Create a new file called ~/.getmail/getmailrc in your home directory (usually /home/user ). This will contain all your account settings. Here’s an example: [retriever] type = SimpleIMAPSSLRetriever server = imap-server.isp.example username = [email protected] password = YourPassword [destination] type = Maildir path = ~/Maildir/username/
If you’re running into problems with getmail, first make sure you’ve followed the installation instructions carefully. Then check the following points in order:
Make sure you have a POP server configured properly and accessible from getmail (see POP servers).
Make sure your system clock is correct (see NTP).
Check your POP server’s log file. You may find an error or warning message there that can help you figure out what’s wrong. If not, try running your POP server in debug mode and see if it gives any useful output; see poplogd(8) for details on how to do this.
Try using another POP3 client to check your mailbox using the same protocol as getmail; this should allow you to verify whether or not getmail is working correctly with your server without getting caught up in any additional complications such as authentication issues.