getmail is intended as a simple replacement for
those people who don't need its various and sundry configuration options,
complexities, and bugs. It retrieves mail from one or more POP3 servers for one
or more email accounts, and reliably delivers into a `Maildir' specified on
a per-account basis. It can now also deliver into `mbox' files, although
this should not be attempted over NFS.
getmail is Copyright (C) 2000 Charles Cazabon.
Licensed under the GNU General Public License version 2. See the file `COPYING' for license details.
There is now a FAQ available about
getmail. Read it
There are links to download
getmail at the bottom of this document.
You can skip directly to them by clicking here.
getmail is a Python script. Ensure the Python interpreter is installed
(version 1.5.1 or higher is recommended; at the time of this writing, the
current version was 1.5.2. See www.python.org for
details). Put the script somewhere with executable permissions (probably 0755).
A simpler Python script which invokes the main
getmail script can be used
to reduce startup time:
#!/usr/bin/python import getmail getmail.main ()
This allows the Python interpreter to cache the contents of the
script in a `.pyc' file. Python will not write these `.pyc'
files for a script invoked on the commandline. The rest of this file assumes
you have a
getmail file which invokes
getmail.py. If you
don't want this, you can make it a symbolic link, or invoke
getmail.py, or rename the main script.
getmail with the `-h' or `--help' options for help.
To retrieve mail for accounts on a one-time basis, run with arguments as follows:
getmail [options] user1@mailhost1[:port],destination1[,password1] user2@mailhost2[:port],destination2[,password2]
For example, to retrieve mail for account `joe' on mailhost `mail.isp.com', running on port 8110, and deliver that mail into the Maildir `Maildir' in your home directory, run as follows:
getmail.py [options] firstname.lastname@example.org:8110,$HOME/Maildir,password
`destination' can be either a `Maildir' or an `mbox' file.
getmail auto-detects `Maildir's, and assumes regular files are
If you omit the final `,password',
getmail will prompt you for your
password. You may omit the `:port' portion if the server runs on the
standard POP3 port (110).
You can retrieve mail for multiple accounts at once, delivering to different maildirs, by specifying multiple arguments:
getmail.py [options] email@example.com:8110,$HOME/Maildir,password firstname.lastname@example.org,$HOME/user2mbox
Note in this case, `mailhost2' is on the standard POP3 port and the user will be prompted only for user2's password.
getmail to retrieve from the same accounts on a regular basis, and to be
able to retrieve only mail messages which
getmail has not previously
retrieved, set up
getmail as follows:
[identifier] account=username host=popmailhost port=port password=password destination=destinationpath[:username] delete=value readall=valueThe options can be specified in any order. Blank lines are ignored, as is anything after a `#' symbol. Leading and trailing whitespace on the option names and values is ignored. To preserve leading or trailing whitespace on an option value (such as a POP password), surround it with either single or double quotes. The meaning of the individual options in each section are as follows:
getmail. Identifiers must be unique, and should be meaningful to you.
getmailwill prompt for passwords.
getmailon). If `:username' is present, files created in `Maildir's will have their ownership changed to the UID and default GID of that system user. This is useful, for example, if you are running getmail as `root' but delivering to another user's `Maildir'.
getmaildeletes the mail from the POP3 server after retrieving it. Valid values include `yes' and `no'. `delete' defaults to `no'.
getmailretrieves all mail, or only unread mail for that account. Valid values include `yes' and `no'. `readall' defaults to 'yes'.
getmailwith no options to retrieve all mail for accounts specified in the .getmailrc file. Use option `-n' or `--new' for only unread mail. Use option `-v' or `--verbose' to see what's going on.
getmailalways be verbose, and always delete retrieved mail from the server, set it to something like `--verbose --delete'. Again, you can set this every time you login in your `.bash_profile' or `.bashrc' file if you use the
getmail understands the following commandline options.
getmailhas previously retrieved.
getmailhas not previously retrieved.
getmail understands the following options in it's configuration
file (e.g. `.getmailrc').
[Joe's home account]
getmailshould deliver all mail from this account into a single destination (type `mailbox'), or deliver to various destinations based on the contents of the headers of each retrieved emssage (type `domainbox'). This is optional and may be omitted for `mailbox' account types.
destination=/home/username/Maildir/ destination=/home/username/Maildir/:username destination=/users/a-f/username/mboxfile
getmailwill prompt for the password when run.
getmailshould delete the mail from the POP3 server after retrieving it. This is optional, and defaults to `no'.
getmailshould retrieve all mail from this account, or just messages which it has not previously seen. This is optional, and defaults to `no'. Note that this option is meaningless if
getmailis deleting mail after retrieving it.
getmailnow forces all email addresses to lower case. This is optionally followed by a colon (`:') and a system username. If the username is provided, message files created in a Maildir for this recipient will have their ownership (UID and GID) changed to match the UID and GID associated with that system account. Note that this only works if
getmailruns with `root' privileges. Typically you would set the username to be the same as the owner of the Maildir
getmailis delivering to.
email@example.com=/users/jsmith/Mail/list-weasels firstname.lastname@example.org=/users/jsmith/Mail/list-perl email@example.com=/users/jsmith/Mail/personal firstname.lastname@example.org=/users/rharrington/Mail/info-requests/:rharrington
I have added support for domain (multidrop) mailboxes. A domain mailbox is a POP3 mailbox which receives mail for multiple users. For example, all mail for anyone at `mycompany.com' might be delivered to a single POP3 mailbox named `email@example.com'.
getmail can be configured to retrieve mail from a domain mailbox, and
deliver each message separately, to the user it was originally addressed to.
This type of operation is not 100% reliable, unfortunately, because of the way
many MTAs implement domain mailboxes.
getmail tries to work around
this by supporting (among other methods) the `Delivered-To: ' header
implemented by more reliable MTAs (like
getmail tries to determine who each message was originally intended for
by looking at the message headers. If the first valid header is a qmail-style
`Delivered-To:' header, it will use that as the recipient. If that header
does not exist, it will look for recipients in `Envelope-To:'. If that
header does not exist, it will check `X-Envelope-To:'. If that header does
not exist, it will look in `Resent-To:', `Resent-cc:', and
`Resent-bcc:' headers. If none of those headers exist, it will look for
recipients in `To:', `cc:', and `bcc:' headers. If
fails to find any email addresses by this point, it will look in `Received:'
getmail compares the recipients it finds against email addresses supplied
in the `.getmailrc' configuration file. For each matching address it finds,
getmail delivers a copy of that message to a destination `Maildir'
or `mbox' file specified for that address. If it finds no matches, it
delivers the message to a default destination, which should be the postmaster or
other person responsible for sorting out email issues in that domain.
Note that the configuration file parser was completely rewritten for version 0.99, so that it removes most of the restrictions that were previously present.
The configuration file section for a domain mailbox should look like this:
[Section title] type = domainbox # whitespace is OK around the `=' account=pop3username # so is leading and trailing whitespace host=pophost.domain password = " pop_password with leading whitespace" destination=/path/to/default_delivery_destination[:username] delete=(yes|no) readall=(yes|no) email@address=/path/to/destination[:username] email@address2=/path/to/destination2[:username] [...]
Some examples of the `email=destination' lines are:
See the file `example.getmailrc' for more details about configuration files.
More details are available in the file `USAGE'.
The current version of
getmail should be available at
To report a bug, make a feature request, or get support with
please send email to me at <getmail @ discworld.dyndns.org>.
This document was generated on 4 April 2000 using the texi2html translator version 1.51a.