# getmail documentation

This is the documentation for getmail version 5. Version 5 includes numerous changes from version 3.x; if you are using getmail version 3, please refer to the documentation included with that version of the software.

getmail is Copyright © 1998-2021 Charles Cazabon. <charlesc-getmail @ pyropus.ca>

getmail is licensed under the GNU General Public License version 2 (only). If you wish to obtain a license to distribute getmail under other terms, please contact me directly.

Note that this license allows you to "fork" getmail. If you do so, please follow open-source/free-software best practices and rename your fork so the package name and executable name do not contain the word "getmail" or anything confusing similar. This helps prevent users mistakenly contacting the wrong people for help. The fork must also remain under the GPLv2 license, and must preserve all existing copyright notices in the code and documentation.

# Table of Contents

- getmail documentation
- - getmail documentation
  - - Features
    - Differences from previous versions
    - A note on Python 3 compatibility
    - - What about a native Python 3 version?
      - What about this "getmail6" version? I heard it supports Python 3?
    - Requirements
    - Obtaining getmail
    - Installing getmail
    - - For the impatient
      - Full installation instructions
      - Installing from the RPM
      - Installing directly from the source
      - - Installing in the default location
        - Installing under an alternate prefix directory
        - Installing parts of the package to alternate directories
      - Installing the getmail5core package in a non-standard location
      - Building a binary package from the source
    - getmail mailing lists
    - - getmail-users' mailing list
      - - How to subscribe
        - How to unsubscribe
        - How to post
        - Archives of the getmail-users' mailing list
        - Notes on the getmail-users' mailing list
      - Announcements List
      - - How to subscribe
        - How to unsubscribe
        - How to post
        - Archives of the getmail announcements mailing list
- getmail configuration
- - Configuring getmail
  - - Creating a getmail rc file
  - Running getmail
  - - Commandline options
    - Using getmail as an MDA
    - Using getmail_fetch to retrieve mail from scripts
- getmail troubleshooting
- - Troubleshooting problems
  - - I get Unicode- or UTF-8-related errors when I run getmail
    - Error messages
    - Warning messages
    - Unexpected Behaviour
- getmail frequently-asked questions (FAQs)
- - Frequently-Asked Questions (FAQs)
  - - About getmail
    - Configuring getmail
    - How do I …
    - Using getmail with other software
    - I think I found this bug in getmail …

## Features

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. getmail is designed to be secure, flexible, reliable, and easy-to-use. getmail is designed to replace other mail retrievers such as fetchmail.

getmail version 5 includes the following features:

- simple to install, configure, and use
- retrieve virtually any mail
  - support for accessing mailboxes with the following protocols:
    - POP3
    - POP3-over-SSL
    - IMAP4
    - IMAP4-over-SSL
    - SDPS (Demon UK's extensions to POP3)
  - support for single-user and domain mailboxes
  - retrieve mail from an unlimited number of mailboxes and servers
  - can remember which mail it has already retrieved, and can be set to only download new messages
- support for message filtering, classification, and annotation by external programs like spam filters and anti-virus programs
- support for delivering messages to different destinations based on the message recipient
- reliability
  - native safe and reliable delivery support for maildirs and mboxrd files, in addition to delivery through arbitrary external message delivery agents (MDAs)
  - does not destroy information by rewriting mail headers
  - does not cause mail loops by doing SMTP injection, and therefore does not require that you run an MTA (like qmail or sendmail) on your host
- written in Python, and therefore easy to extend or customize
  - a flexible, extensible architecture so that support for new mail access protocols, message filtering operations, or destination types can be easily added
  - cross-platform operation; getmail 5 should work on Unix/Linux, Macintosh, and other platforms. Windows support available under the free Cygwin package.
- winner of various software awards, including DaveCentral's "Best of Linux"

## Differences from previous versions

getmail version 4/5 has been completely rewritten. It is designed to closely mimic the interface and user experience of getmail version 3, but the new architecture necessitates some differences you will notice:

- the getmail rc file (configuration file) format has changed. If you are upgrading from version 3, you will need to write a new configuration file based on the contents of your old one. The new file format resembles the old in many ways. Each account you retrieve mail from will require a separate rc file, but getmail can operate with multiple rc files simultaneously if you wish to retrieve mail from multiple accounts.
- support for protocols other than POP3/SDPS. IMAP support is now included, and other protocols can be added with relative ease.
- support for SSL-encrypted protocols. The included POP3 and IMAP retriever classes are complemented by SSL-enabled counterparts.
- messages can be filtered or annotated by external programs like spam filters and anti-Microsoft-worm programs. Filters can cause messages to be dropped completely.
- a flexible, extensible architecture. Additional classes for handling new mail protocols, filter types, or destination mailstores can be added without needing to modify the main script at all. Feel free to contact me if you need a custom retriever, filter, or destination class written, or if you want commercial support for getmail.

## A note on Python 3 compatibility

getmail currently requires Python version 2.x, and is not currently compatible with Python 3. Various Linux/etc distributions have removed Python 2 from their distributions, or disabled it by default, because Python 2 has reached end-of-support.

Using Python 2 with getmail does not constitute a security risk.

To use Python 2.7 with a Linux/etc distribution which has disabled or removed Python 2, you will need to install it using one of these methods:

- install Python 2.7 from a non-default package shipped by your distribution. This may be named python2.7, python27, python-2.7 or similar. For example, Debian and Ubuntu ship python2.7, Redhat/CentOS ship python-2.7, and most other distributions have something similar. MacOS should have Python 2.7 available through homebrew or other add-on repositories.
- Installers are available for MacOS and Windows from the Python.org site.
- If you cannot find a package for your distribution (and you probably should be able to), you can download a single-file executable "AppImage" containing Python 2.7 and the standard library. Just download the file, make it executable, rename it "python2" or create a symlink of that name pointing to the AppImage file, and put it in /usr/local/bin/, and getmail will happily run with it.
  For example, on an x86_64 Linux system, you could:

      wget https://github.com/niess/python-appimage/releases/download/python2.7/python2.7.18-cp27-cp27m-manylinux1_x86_64.AppImage
      sudo install -m 755 python2.7.18-cp27-cp27m-manylinux1_x86_64.AppImage /usr/local/bin/
      sudo ln -sr /usr/local/bin/python2.7.18-cp27-cp27m-manylinux1_x86_64.AppImage /usr/local/bin/python2

  That's all that's necessary.
- You can build it from source, but I do not recommend this. It's not terribly difficult, but ensuring you get proper SSL/TLS support built-in can be fiddly and annoying.

### What about a native Python 3 version?

People ask why getmail isn't already Python 3 compatible. Partly it's because converting it will almost certainly break compatibility with Python 2, which is still in wide use in network appliances and other embedded systems where Python 3 may not be available.

There is also the issue that doing a proper Python 3 conversion of getmail will be a significant amount of work. There is an automated "2to3" converter, but it cannot make all the necessary changes, so there is still a lot of manual fixups to make afterwards, and it results in ugly, hard-to-maintain code. Doing a proper conversion is on my list of things to do - it will be more of a rewrite, leaving getmail v5 around for legacy systems, and cleaning up much of the historical baggage getmail has accumulated over the last 23 years. But the time I have available for Free Software these days is a lot less than it was 23 years ago, so it will be a while before this is complete and ready for use.

### What about this "getmail6" version? I heard it supports Python 3?

"getmail6" isn't getmail. I have nothing to do with it, by the choice of its maintainer. In its current state as of this writing, it is actually not in compliance with the GNU GPLv2 license, and is therefore not even legal to distribute.

It's a presumably-hostile fork that someone else did. They ran getmail through the automated 2-to-3 converter program as described above, and then started hacking in fixes until it would run under Python 3. They have not done a good job of this; I started receiving a lot of bug reports and help requests from users who were running this version. Those bugs indicate, among other things, that this maintainer did not properly handle text/unicode vs bytes issues in the conversion. I have no confidence that they have fixed all of the bugs they introduced when they did this conversion. It's possible it corrupts or loses mail, or is otherwise somehow disastrously buggy, and I do not recommend its use by anyone.

Why do I say it's a "hostile" fork? Because I have communicated with the maintainer and indicated I would be thrilled to accept their changes bringing Python 3 compatibility, as long as they were in reviewable condition, so that I could be sure I wasn't introducing bugs into getmail when I merged their changes.

I also asked, nicely, for them to change the name of their fork to something other than "getmail", as that is the polite, best-practice thing to do when forking a Free Software project.

That maintainer has shown precisely zero interest in submitting his changes for me to merge into getmail; he literally ignores every question/request I have made on the subject. On the name change, he outright refuses and claims he has the right to use my project name as much as I do, which is ... distinctly unfriendly. So people run into problems with "getmail6", and they think it's an official version of getmail from me, and that it is buggy, and they seek help from me or the getmail users' mailing list.

Unfortunately, some Linux distributions have dropped getmail packages and included "getmail6" packages when they deprecated Python 2.7 and stopped installing it by default. So some users have had getmail replaced out from underneath them without even a notice or warning; they don't even know they're now running "getmail6" instead of getmail. So I've spent a lot of time walking people through problems and bug reports, only to find later that they're not actually running getmail, and the problem is in this other package.

Debian has apparently agreed to remove the "getmail6" package, and it should happen soon. I originally suggested they keep distributing it, but simply rename the package and executable, given that its maintainer outright refuses to do so. But apparently they'd rather drop it.

I have not yet made the effort to find all distributions that have silently "upgraded" users from getmail to "getmail6". If any getmail users would care to discuss this issue with their distribution's maintainers, I would be happy to participate in the discussion.

## Requirements

getmail version 5 requires Python version 2.3.3 or later. If you have only an earlier version of Python available, you can install the latest version without disturbing your current version, or use getmail version 3, which requires only Python version 1.5.2 or later.

At the time of this writing, the current stable version of Python is 2.3.4. You can download that version from the page at http://www.python.org/2.3.4/ . Binary packages are available for RPM-based Linux systems, or building Python from source is typically as easy as unpacking the source tarball, and running the following commands:

    ./configure
    make
    make install

Since the above was written, Python 2.4 has been released. getmail 5 will work with that version of Python as well.

getmail 5 also requires that servers uniquely identify the messages they provide (via the UIDL command) to getmail for full functionality. Certain very old or broken POP3 servers may not be capable of this (I have had only one report of such problems from among the tens of thousands of people who have downloaded getmail 5 from my website and from other archives), or may not implement the UIDL command at all, and limited support is available for such servers via the BrokenUIDLPOP3Retriever and BrokenUIDLPOP3SSLRetriever retriever classes.

## Obtaining getmail

Download getmail 5 from the official website main page at http://pyropus.ca/software/getmail/ .

## Installing getmail

### For the impatient

Installing getmail is very easy; just download the tarball distribution, unpack it, change into the directory it unpacks into, and run this command:

    $ python setup.py install

That's all there is to it. 99.9% of users don't need a special package/port/etc. If you'd like more details on install options, keep reading.

### Full installation instructions

Once you have downloaded or otherwise obtained getmail, unpack it. On GNU-ish Unix-like systems, this means:

    $ tar xzf getmail-version.tar.gz

On Macintosh systems, use a Zip-type archiver program to unpack the tarball.

On SystemV-like Unix systems, you may instead need to break this down into two steps:

    $ gunzip getmail-version.tar.gz
    $ tar xf getmail-version.tar

Then, change into the extracted getmail directory and start the build process. The easiest installation method is to use the included setup.py Python distutils script to build and install getmail directly. Alternatively, you can build a binary package (i.e., an RPM or similar managed software package) for your system from the source package and install the resulting package, but the Python distutils support for this is spotty at present.

### Installing from the RPM

If you downloaded the RPM, you should be able to install it with the following command:

    $ rpm -ihv getmail-version-release.noarch.rpm

### Installing directly from the source

To build and install directly from the included source, follow these steps.

    $ cd getmail-version
    $ python setup.py build

When that completes in a few seconds, become root and then install the software. You can install in the default location, or specify an alternate location to install the software, or specify alternate directories for only part of the package.

#### Installing in the default location

To install in the default location, become user root and install with the following commands:

    $ su
    enter root password
    # python setup.py install

This will, by default, install files into subdirectories under the directory prefix, which is the directory that your Python installation was configured to install under (typically /usr/local/ or /usr/, but other values are sometimes used):

- the scripts getmail, getmail_fetch, getmail_maildir, and getmail_mbox will be installed under prefix/bin/
- the Python package getmail5core (which implements all the protocol–, filter–, and destination-specific code for getmail, plus various other bits) will be installed under the site-specific packages directory of your Python library directory. This directory is prefix/lib/python-python-version/site-packages/.
- The documentation directory getmail-getmail-version will be installed under prefix/doc/
- The manual pages for the four scripts will be installed under prefix/man/

You can see a list of the default installation locations by running:

    # python setup.py install --show-default-install-dirs

#### Installing under an alternate prefix directory

You can specify an alternate prefix directory by supplying the --prefix option to the install command, like this:

    # python setup.py install --prefix=path

This will install the various parts of the package in subdirectories like in the default installation (see the section Installing in the default location above), but under your specified prefix directory. These alternate installations allow you to install the software without root privileges (say, by installing under $HOME/). Note, however, that the getmail5core package will not be in the default Python module search path if you do this; see the section Installing the getmail5core package in a non-standard location if you use this option.

#### Installing parts of the package to alternate directories

If you only want to change the directory for some of the components, use the following options:

- --install-lib=path specifies the directory the getmail5core package is installed under (i.e., it will be installed as path/getmail5core ). See the section Installing the getmail5core package in a non-standard location if you use this option.
- --install-scripts=path specifies the directory the four scripts are installed under (i.e., they will be installed directly in path/ ).
- --install-data=path specifies the directory the documentation is installed under (i.e., the HTML and plaintext documentation will be installed in the directory path/doc/getmail-getmail-version/, and the man(1) pages will be installed in path/man/man1/.

For example, if your Python installation is located under /usr/ because it was installed as part of your OS, but you would like the getmail scripts installed into /usr/local/bin/ instead of /usr/bin/, while still letting the getmail5core package be installed under /usr/lib/python-python-version/site-packages/, and the documentation and man pages under /usr/doc/ and /usr/man/ you could use this command to install:

    # python setup.py --install-scripts=/usr/local/bin/

If you also wanted to locate the documentation and man pages under /usr/local/ but still install the getmail5core package in the default /usr/lib/python-python-version/site-packages/, you would instead use this command to install:

    # python setup.py --install-scripts=/usr/local/bin/ --install-data=/usr/local/

### Installing the getmail5core package in a non-standard location

Note: if you use one of the above methods to install the getmail5core package into a directory other than the default, the four scripts (getmail, getmail_fetch, getmail_maildir, and getmail_mbox) will almost certainly be unable to locate the required files from the getmail5core package, because they will not be in a directory in the standard Python module search path. You will need to do one of the following to make those files available to the scripts:

- set the environment variable PYTHONPATH to tell Python where to find the appropriate modules. See the documentation at the Python.org website for details.

  Note that setting PYTHONPATH in $HOME/.profile (or equivalent) is not sufficient -- for instance, cron runs jobs in a simpler environment, ignoring $HOME/.profile, and getmail would therefore fail when run as a user cron job. It is strongly recommended that you install the Python library files in the site-packages directory which Python provides for exactly this reason.

- modify the scripts to explicitly tell Python where you've installed them. Insert a line like this:

      sys.path.append('/path/to/installation-directory')

  containing the path to the directory you installed the getmail5core directory in, somewhere below the line which reads

      import sys

  and before the first line which references getmail5core .

### Building a binary package from the source

To build a binary package from the included source, run the following command from inside the unpacked getmail source.

    $ cd getmail-version
    $ python setup.py bdist --format=package-format

The useful allowed values for package-format are:

- rpm — build a .noarch.rpm file which can then be installed with the rpm package manager.
- pkgtool — build a package for the Sun Solaris pkgtool package manager.
- sdux — build a package for the HP/UX swinstall software installer.

Ideally, if you use this method, it will result in a "built distribution" binary package in a subdirectory named dist which can then be installed using the appropriate system-specific tool. If you have problems with this process, please do not ask me for assistance; ask your OS vendor or the comp.lang.python newsgroup. The install-directory-from-source process above is the only one I can support, and it should work on all platforms.

You can discuss issues with building binary packages on the getmail users' mailing list.

## getmail mailing lists

### getmail-users' mailing list

A mailing list has been set up to discuss getmail. Only subscribers may post to the list.

The list is available for free getmail support from me and other users, for discussions of bugs, configuration issues, documentation, and other technical issues related to getmail.

#### How to subscribe

To subscribe to the list, send a blank email to <getmail-subscribe @ lists.pyropus.ca> and follow the instructions in the message you receive. Read and save the "welcome" message you receive when you subscribe; it contains valuable instructions about how to use the list.

#### How to unsubscribe

To un-subscribe from the list, send a blank email from the same address you subscribed with to <getmail-unsubscribe @ lists.pyropus.ca> and follow the instructions in the message you receive.

#### How to post

Once you have subscribed to the list, you may post messages to the list by sending them to <getmail @ lists.pyropus.ca>. Complete instructions for using the list are sent to you when you subscribe.

The list allows plaintext message bodies and plaintext attachments. Do not attempt to send binary files (gzip, etc), HTML, or other types, as they will be stripped from your message.

Note: please ensure you have read the documentation and Frequently Asked Questions, and browsed/searched the mailing list archives before posting a question to the mailing list.

#### Archives of the getmail-users' mailing list

There are browsable archives of the list at https://marc.info/?l=getmail and http://news.gmane.org/gmane.mail.getmail.user . The GMANE getmail users' archive is also available via NNTP if you prefer to read it with a newsreader, rather than a web browser.

#### Notes on the getmail-users' mailing list

When subscribing to the getmail users' mailing list, please note the following:

- The mailing list software does not, and will not munge the Reply-To: header of list messages. I encourage you to read and post to the list using a good MUA that properly supports reply-to-list and reply-to-author functionality. If your MUA lacks a reply-to-list function, you'll need to manually ensure your followup messages to the the list are actually directed to the list submission address.
- The mailing list software does not munge the Subject: header of list messages, so don't look for "[getmail-users]" or anything like that. If you want your MUA to recognize list messages, there are a number of header fields added to allow it to do so.
- Subscribing and unsubscribing from the list are both secure and completely automatic. When you try to do either, the list manager software will send you a special message you have to reply to to finish the operation; this prevents others from subscribing you to or unsubscribing you from the list without your permission.
- You must be a list subscriber to post messages to the list.

### Announcements List

If you only want to be notified of new releases of getmail, an announce-only list has been set up. The list is very low-volume; you can expect to receive only a small number of messages per month.

All announcements are sent to both lists, so there is no need to subscribe to the announcements list if you are on the discussion list.

#### How to subscribe

To subscribe to the list, send a blank email to <getmail-announce-subscribe @ lists.pyropus.ca> and follow the instructions in the message you receive. Read and save the "welcome" message you receive when you subscribe; it contains valuable instructions about how to use the list.

#### How to unsubscribe

To un-subscribe from the list, send a blank email from the same address you subscribed with to <getmail-announce-unsubscribe @ lists.pyropus.ca> and follow the instructions in the message you receive.

#### How to post

You cannot post messages directly to the announcements list. If you feel you have an announcement regarding getmail which should be distributed, send it to me and request that I send it to the announcements list.

#### Archives of the getmail announcements mailing list

There is an archive of the announcements list at http://news.gmane.org/gmane.mail.getmail.announce . The GMANE getmail announcements archive is also available via NNTP if you prefer to read it with a newsreader, rather than a web browser.