getmail documentation

This is the documentation for getmail version 4. Version 4 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-2009 Charles Cazabon.

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.

Table of Contents

Frequently-Asked Questions (FAQs)

The following questions about getmail are answered more-or-less frequently. Please also read the unexpected behaviour section of the troubleshooting document.

About getmail

What is getmail?

getmail is a mail retriever with support for POP3, POP3-over-SSL, IMAP4, IMAP4-over-SSL, and SDPS mail accounts. It supports normal single-user mail accounts and multidrop (domain) mailboxes. getmail is written in Python, and licensed under the GNU General Public License version 2.

What platforms/machines does getmail run on?

getmail runs on basically any platform. It's designed to, and written in a language that helps to maintain cross-platform compatibility. getmail is known to run on the following platforms:

But getmail will also run on other, less common platforms. The only real requirement is that Python run on that platform, and porting Python is generally very easy.

Does getmail run on MS Windows?

Yes, under the free Cygwin package. Running recent versions of Python under Cygwin requires a process known as "rebasing" your Cygwin installation; you can find details in this Python developers' mailing list message.

Does getmail run on Macintosh systems?

Yes.

Does getmail require Unix/Linux?

No.

How can I get support for getmail?

getmail is Free Software. As such, it comes with no warranty. However, I will do my best to support getmail on a voluntary basis through the getmail mailing list.

If you are using getmail in a commercial or other environment where problems cost money, consider contacting me privately for commercial support, by emailing <charlesc-getmail-support @ pyropus.ca>

If you have questions about getmail, the first step is to read the documentation, and the remainder of the Frequently Asked Questions. If your question isn't answered there, search the getmail mailing list archives.

If you still haven't found an answer to your question, please subscribe to the getmail users' mailing list by sending a blank email to <getmail-subscribe @ lists.pyropus.ca>. If you post your question there, I will see it. As an additional bonus, your question may be answered by another member of the list.

I think I found a bug! How do I report it?

First, make sure that you are running the latest version. You can always find what is the latest version by checking this page at the original web site:
http://pyropus.ca/software/getmail/.
If you running an older version of the software, chances are whatever bug you may have found has already been fixed.

Ideally, you should join the mailing list and send your bug report there. You should include the following information:

If you absolutely cannot sign up for the mailing list, send the report to me directly at <charlesc-getmail-bugs @ pyropus.ca>. I may not be able to respond to all reports privately, but I will try to address any bugs I find out about this way.

I have a neat idea for random feature "foo" … how do I get you to implement it?

Follow the same instructions as for reporting bugs above — yes, that means I would prefer you submit your idea to the getmail users' mailing list. That will lead to a useful discussion if your feature has not been proposed before.

Why won't you implement random feature "foo"?

Every line of code added to getmail has a certain cost. Every feature added requires code, documentation, and support. Adding features increases the complexity of the software, confuses users, and leads to higher support costs. I therefore weigh features very carefully as a cost-versus-benefit tradeoff before deciding whether to add them.

Some users are confused by this. They think that a feature you don't use has no cost, and therefore if it has any value to anyone, it should be added. That simply isn't the case; the costs of an unused feature are simply borne by others, including me.

If you have asked me to add some feature, and I've said no, this may be the reason. Other possibilities include me simply not having had sufficient time to implement it yet.

Does getmail support virus scanning of retrieved messages?

Yes. You can use getmail message filtering options to do this with an external virus scanning program, or invoke your virus scanning program during delivery with getmail's support for external MDAs.

Also see the FAQ about using getmail with the ClamAV program.

Does getmail support spam filtering of retrieved messages?

Yes. You can use getmail message filtering options to do this with an external spam filtering program, or invoke your spam filtering program during delivery with getmail's support for external MDAs.

Also see the FAQ about using getmail with the SpamAssassin program.

Does getmail support SSL?

Yes. getmail has built in support for POP3-over-SSL and IMAP4-over-SSL.

Does getmail rewrite mail headers when it retrieves mail?

No. Rewriting message header fields is bad for many reasons; the biggest problem is that it causes a loss of critical technical information necessary to track down many mail problems. getmail will add a new Received: header field and a new Delivered-To: header field, but does not rewrite existing headers. You can disable the creation of these header fields.

Can I upgrade from getmail 3 to getmail 4? What about my "oldmail" files?

Yes. getmail version 4 uses exactly the same oldmail-server-port-username naming convention for its oldmail files. The only difference is that version 4 escapes a couple of additional characters in this string so that it is truly cross-platform compatible. If you upgrade from version 3 to version 4, getmail will still remember which messages you've already retrieved.

To upgrade, do the following:

  1. Rename your old getmail rc file, creating a new file in ~/.getmail/getmailrc.
  2. Create a new [options] section, containing the appropriate values from your version 3 rc file [defaults] section.
  3. Create a new [retriever] section, using your previous server configuration values in a new type = SimplePOP3Retriever or type = MultidropPOP3Retriever as appropriate.
  4. Create a new [destination] section, using your previous destination path values in a new type = Maildir, type = Mboxrd, type = MDA_external, or type = MultiSorter destination as appropriate.
  5. If you were retrieving messages from multiple mail accounts in a single version 3 getmail rc file, split them up into one account per version 4 rc file.

That's it.

Why did you write getmail? Why not just use fetchmail?

Short answer: … well, the short answer is mostly unprintable. The long answer is … well, long:

I do not like some of the design choices which were made with fetchmail. getmail does things a little differently, and for my purposes, better. In addition, most people find getmail easier to configure and use than fetchmail. Perhaps most importantly, getmail goes to great lengths to ensure that mail is never lost, while fetchmail (in its default configuration) frequently loses mail, causes mail loops, bounces legitimate messages, and causes many other problems.

When people have pointed out problems in fetchmail's design and implementation, it's maintainer has frequently ignored them, or (worse yet) gone in the completely wrong direction in the name of "fixing" the problems. For instance, fetchmail's configuration file syntax has been criticized as being needlessly difficult to write; instead of cleaning up the syntax, the maintainer instead included a GUI configuration-file-writing program, leading to comments like:

The punchline is that fetchmail sucks, even if it does have giddily-engineered whizbang configurator apps.

As an example, Dan Bernstein, author of qmail and other software packages, once noted to the qmail list:

Last night, root@xxxxxxxxxxxxxxxxx reinjected thirty old messages from various authors to qmail@xxxxxxxxxxxxxx

This sort of idiocy happens much more often than most subscribers know, thanks to a broken piece of software by Eric Raymond called fetchmail. Fortunately, qmail and ezmlm have loop-prevention mechanisms that stop these messages before they are distributed to subscribers. The messages end up bouncing to the wrong place, thanks to another fetchmail bug, but at least the mailing list is protected.

--D. J. Bernstein

The maintainer also ignored dozens of complaints about fetchmail's behaviour, stating (by fiat) that fetchmail was bug-free and had entered "maintenance mode", allowing him to ignore further bug reports.

fetchmail's default configuration values frequently cause lost or misdirected mail, and seem to be chosen to cause maximum pain and inconvenience. From fetchmail's to-do file (emphasis mine):

Maybe refuse multidrop configuration unless "envelope" is _explicitly_ configured … This would prevent a significant class of shoot-self-in-foot problems.

perhaps treat a delivery as "temporarily failed" … This is so you don't lose mail if you configure the wrong envelope header.

fetchmail is famous for mangling messages it retrieves, rather than leaving them alone as a mail-handling program should. getmail will add trace information to messages (so you can see what happened, and when), but will otherwise leave message content alone.

In addition, fetchmail has a long history of security problems:

In July, 2004, it was noted that there may be at least 2 unfixed denial-of-service attacks, 2 unfixed remote-code-execution, 2 unfixed remote-user-access, and 3 unfixed remote-shell attacks against fetchmail. See http://www.mail-archive.com/euglug@euglug.org/msg00971.html for details

I've given up even trying to stay abreast of the various security holes in fetchmail, but others have noted continuing problems, including:

The fetchmail authors' boneheaded decision to create a configuration-file GUI editor (rather than actually giving fetchmail a sane configuration syntax) also came back to bite them in the ass: in October 2005, it became known that fetchmailconf created its files in such a way that users' passwords could be read during file creation.

Addendum, January 2007: since I wrote the above, the following new security problems have been discovered in fetchmail:

But don't just take my word for it; see http://docs.freebsd.org/cgi/mid.cgi?200102172349.QAA11724 and http://esr.1accesshost.com/ (note: went offline sometime in 2009 or 2010; the content is still available at http://web.archive.org/web/20080621090439/http://esr.1accesshost.com/ ).

getmail users have not had to worry about any of these security holes or design and implementation errors.

Configuring getmail

What is a "domain mailbox"?

A domain (or multidrop) mailbox is a POP3 mailbox which receives mail for all users in a given domain. Normal mailboxes contain mail for a single user (like jason@myisp.co.uk); some Internet Service Providers which provide webhosting or other services will provide a POP3 mailbox which receives mail for all addresses in a given domain (i.e. mail for service@smallcompany.net, sales@smallcompany.net, and indeed anything @smallcompany.net ends up in the same POP3 mailbox).

getmail provides a method of retrieving mail from a domain mailbox and distributing it among the various users automatically. The retriever classes MultidropPOP3Retriever, MultidropPOP3SSLRetriever, MultidropSDPSRetriever, MultidropIMAPRetriever, and MultidropIMAPSSLRetriever provide this capability.

See the documentation on the [retriever] section for details of what the requirements for a multidrop mailbox are. getmail user Matthias Andree also has a web page about multidrop mailboxes.

Do I have to run sendmail or another MTA to use getmail?

No. getmail delivers directly to maildirs, mboxrd files, or via arbitrary MDAs, and never injects mail via SMTP, so no MTA is necessary.

Will getmail deliver mail as root?

No. When run as the root user on a Unix-like system, getmail drops privileges (switches to an unprivileged group and user id) before delivering to maildirs or mboxrd files. You can specify the user explicitly, or let getmail use the owner of the maildir or mboxrd file.

If getmail attempts to deliver mail and finds it has UID 0 or GID 0, it will refuse the delivery and print an error message.

What's a maildir?

A maildir is a mail storage format invented by D. J. Bernstein (author of qmail) that requires no file locking to deliver to safely and reliably, even over NFS. getmail natively supports delivery to maildirs.

See http://qmail.org/man/man5/maildir.html and http://cr.yp.to/proto/maildir.html for details.

What's "mboxrd" format?

There are various sub-types of the mbox mail storage format. mboxrd is the most reliable of them, though (like all mbox types) it still relies on file locking and is therefore more easily corrupted than maildir format. In particular, using mbox files with multiple writers over NFS can be problematic.

For details on the differences between the various mbox sub-types, see http://qmail.org/man/man5/mbox.html.

What's this "envelope sender" and "envelope recipient" stuff?

The "envelope" of an email message is "message metadata"; that is, the message is information, and the envelope is information about the message (information about other information). Knowing this is critical to understanding what a domain or multidrop mailbox is, how it works, and what getmail can do for you.

Others have tried to explain this with varying degrees of success. I'll use the standard analogy of normal postal (i.e. non-electronic) mail:

Message header vs. message envelope

When you receive a letter (a reply from the customer-disservice department of your telephone company, say) it arrives in an envelope. You tear it open, remove the letter, and read it. At the top of the letter is the telephone company's return address, followed by the date the letter was written. Your name and mailing address follow that, and then the remainder of the letter.

The important thing to keep in mind is that the contents of the letter (including the addresses just discussed) are never looked at by the post office. If they can't deliver the letter (your mailing address on the envelope got smudged in the rain), they'll return it to the address listed in the top-left corner of the envelope. They don't check to make sure that the address listed there is the same as the one listed at the top of the letter. Similarly, when they can successfully deliver it, they don't check to make sure that the recipient name and address on the envelope matches the one listed on the letter between the date and the salutation.

The message header fields From: and Resent-from: are equivalent to the block of address information at the top of the letter; it usually contains the name and address of the sender of the message, but it is never actually used in the delivery of the message. Similarly, the To:, cc:, Resent-to:, and Resent-cc: header fields are the equivalent of the block of address information between the date and the salutation on the letter; they usually contain the names and addresses of the intended recipients of the message, but they too are not used in the delivery of the message.

Receiving messages without your address in the message header

You might open an envelope addressed to you and find that the letter inside makes no mention of your name. Your name and address don't appear anywhere in the letter, but it was still successfully delivered to you based on the envelope information. There's nothing strange about this. If someone else opens your mail for you, discards the envelopes, and places the contents in your in-basket, you might wonder how some of it ended up there, because there's nothing to connect you with the message contents.

Email is exactly like this. Each message has two parts, the message contents, and the message envelope. The message contents include the message header, and the message body. The message envelope is made up of exactly one envelope sender address (which can be empty) and one or more envelope recipient addresses. If the message cannot be delivered for any reason, and the envelope sender address is not empty, the message must be returned to the envelope sender address by the mail transfer agent (MTA) which last accepted responsibility for delivering the message. These notifications are known as "bounce messages" or sometimes as "non-delivery notifications". Bounce messages are sent using the empty envelope return path, to prevent mail loops from occurring when a bounce message itself cannot be delivered.

Confusion often arises among novice users about the difference between the message header and the message envelope; they seem to believe that they are not independant. This appears to be an artifact of their use of simple-minded GUI mail user agents (MUAs) that do not allow them to set the envelopes of their messages explicitly, but instead simply use the contents of the From: header field as the envelope sender address, and any addresses found in To:, cc:, and bcc: header fields as the envelope recipient addresses. While these are sensible as default values, more powerful MUAs allow the user to override this choice.

Responsibility for recording the message envelope

The last MTA to receive a message (usually the one running on the POP or IMAP server where you retrieve your mail from) essentially acts as your correspondence secretary, accepting your mail from the postman, opening it, and placing it into your in-basket. Note that this would normally destroy the important information contained in the message envelope. To prevent this loss of information, this MTA is supposed to copy the information from the envelope into new fields in the header of the message content, as if your secretrary copied the sender and recipient addresses onto the back of your letters in felt pen. Unfortunately, some MTAs do not always do this properly, and envelope information can then be lost. When this happens, it makes dealing with certain types of mail messages problematic:

MTAs are supposed to record the envelope sender address by placing it into a new Return-Path: header field at the top of the message. They should then record the envelope recipient address(es) in another new header field; sometimes this header field is named Delivered-To:, but it can also be Envelope-To: or one of a few other names.

How this relates to domain or multidrop mailboxes

A domain or multidrop mailbox is one which receives mail for multiple email addresses (commonly all addresses in a given domain). If you do not want all of this mail to go to one person, you need to know who the messages were originally addressed to after retrieving them from the POP/IMAP multidrop mailbox. You cannot do this by looking at the To:, cc:, or other informational message header fields, because they do not actually reflect the message envelope at the time of delivery. Instead, you have to reconstruct the envelope information from the message header fields which the MTA on the server used to record it at the time of delivery.

If the final MTA does not record the message envelope (the envelope sender, and all envelope recipient addresses in the domain mailbox the message was sent to), then mail will be lost or misdirected regardless of which software you use to access the mailbox. The mailbox cannot actually be said to be a domain mailbox in this case; the defining characteristic of a domain mailbox is that it records the envelope correctly. The configuration of the MTA running on the server needs to be fixed so that the envelope is properly recorded for every message it receives.

This rc stuff seems complicated. Does it have to be?

The configuration file format is actually very simple; you don't need to worry about most of it if you're not interested in using those features. The simplest and most common getmail rc file configuration will be for users who want to retrieve all mail from a single-user POP3 mailbox, deliver those messages to a maildir or mbox file, and delete the mail from the server. For maildir, that configuration is:

[options]
delete = True

[retriever]
type = SimplePOP3Retriever
server = my-pop3-servername
username = my-pop3-username
password = my-pop3-password

[destination]
type = Maildir
path = ~/Maildir/

For an mbox file, that configuration is:

[options]
delete = True

[retriever]
type = SimplePOP3Retriever
server = my-pop3-servername
username = my-pop3-username
password = my-pop3-password

[destination]
type = Mboxrd
path = ~/inbox

How do I …

How do I retrieve mail from multiple accounts?

Create a separate getmail rc file for each account, and run getmail with multiple --rcfile options.

Of course, it's really easy to script this for a large number of rc-* files. You might create a script in $HOME/bin/run-getmail.sh containing:

#!/bin/sh
set -e
cd /path/to/my-rc-directory
rcfiles=""
for file in rc-* ; do
  rcfiles="$rcfiles --rcfile $file"
done
exec /path/to/getmail $rcfiles $@

See any beginner's tutorial on Unix shell scripting for details.

How do I get getmail to deliver messages to different mailboxes based on …

If you want getmail to sort messages based on who they're from, or what address appears in the To: or cc: header fields, or based on the Subject: field contents, or anything like that, pick a filtering MDA (like maildrop or procmail), and call it from a getmail MDA_external destination.

How do I stop getmail adding a Delivered-To: header to messages?

Use the delivered_to [options] parameter.

How do I stop getmail adding a Received: header to messages?

Use the received [options] parameter.

How do I make getmail deliver messages by re-injecting with SMTP?

You don't need to. getmail can deliver to maildirs, mboxrd files, or through arbitrary external MDAs.

If you still think you need to, you can use getmail's external MDA support to do so.

How do I create a maildir?

Use the maildirmake command, if you have it installed. Otherwise, run the following command from your shell:

$ mkdir -p /path/to/Maildir/{cur,new,tmp}

Some other maildir-aware programs ship with their own maildir-creation programs; you can use those, or make the above shell command a shellscript or alias if you like.

How do I create an mboxrd file?

Create a completely empty (i.e. zero bytes long) file via your favourite method. The standard utility touch is commonly used:

$ touch /path/to/mboxrd

How do I make getmail deliver messages to an mh folder?

mh clients (and nmh, or "new mh" clients) include a command for delivering a message into your mh folder. In nmh, this command is called rcvstore. You use it as an external message delivery agent (MDA) with getmail's MDA_external destination. Ensure your $HOME/.mh_profile file is configured properly; getmail user Frankye Fattarelli suggests a line like the following is necessary to indicate the path to your mh mail root:

Path: Mail

Then use MDA_external like this (which, after adjusting the path of the command to reflect your mh/nmh installation, should work with either mh or nmh):

[destination]
type = MDA_external
path = /usr/local/libexec/nmh/rcvstore
arguments = ("+inbox", )

Thanks to Frankye Fattarelli for contributing this answer.

How do I run getmail in "daemon" mode?

Use your system's cron utility to run getmail periodically if you wish to have mail retrieved automatically at intervals. This is precisely what cron is designed to do; there's no need to add special code to getmail to do this.

With a reasonably standard system cron utility, a crontab(5) entry like the following will make getmail retrieve mail every hour:

0 * * * * /usr/local/bin/getmail --quiet

How do I make getmail stop after retrieving X messages so that the server actually flushes deleted messages?

Use the max_messages_per_session option to limit the number of messages getmail will process in a single session. Some users with flaky servers use this option to reduce the chances of seeing messages more than once if the server dies in mid-session.

How do I make getmail retrieve mail from Hotmail?

Well, you could write a retriever that speaks Hotmail's proprietary, undocumented, and unsupported access protocol (or pay me to write one), or simply set up the POP3 proxy from the httpmail package, and have getmail retrieve mail from that POP3 proxy.

I'm using getmail. How do I make it …

These are supplementary questions I occasionally see about doing various things to enhance a getmail setup. The solution to many of them is to use a standard Unix technique of some sort to make the system behave in a certain manner, or otherwise change the behaviour of something that's actually outside of getmail proper.

I'm running getmail from cron. How do I temporarily stop it?

Some people ask about temporarily stopping getmail from running from a cron job, possibly because the mail server is down and they don't want to see the warnings cron mails them.

The easiest method is to comment out getmail from your crontab file:

  1. Run
    $ crontab -e
    to edit your crontab file.
  2. Place a # (pound) character at the start of the line containing the call to getmail.
  3. Save the changed file.

When you want to re-enable getmail, edit the file again and un-do the above change.

If you need to do this on a regular basis, you can instead use a "flag file" to tell the system whether or not to run getmail:

Change your cron job or shellscript that normally launches getmail to check for the presence of a certain file first, and have it not run getmail if that file is present. For example, your crontab entry could be changed to do this:

    [ -f ~/.getmail/do-not-run ] || /path/to/getmail

When you don't want getmail to run, touch that file:

    $ touch ~/.getmail/do-not-run

When you want getmail to run again, delete it:

    $ rm -f ~/.getmail/do-not-run

This is even safe for scripting, as creating and removing the file are atomic operations under Unix.

How do I stop multiple instances of getmail from running at the same time?

getmail has no problems running multiple instances in parallel, though you shouldn't attempt to use the same getmail rc file from two different instances at the same time. If you need to prevent two instances of getmail from running simultaneously, use any standard Unix method of providing a mutex for this purpose. One example would be to run getmail under a program like setlock (part of the daemontools package). Change your script or crontab file to invoke getmail like this:

/path/to/setlock -n /path/to/lockfile /path/to/getmail [getmail options]

There are other programs that provide functionality similar to setlock.

Using getmail with other software

getmail user Frankye Fattarelli contributed to the following questions about integrating getmail with SpamAssassin and ClamAV.

How do I use SpamAssassin with getmail?

SpamAssassin can be run in standalone mode or in a client/server configuration. In both configurations, SpamAssassin accepts a wide variety of arguments; please refer to SpamAssassin's manual pages or online documentation for details.

To filter messages through SpamAssassin in a client/server configuration (i.e. with the spamd daemon), use a configuration like this:

[filter]
type = Filter_external
path = /usr/local/bin/spamc
arguments = ("-s 10000", )

The value supplied to the -s option is the maximum message size accepted (in bytes). The default is 250k.

A similar configuration without the spamd daemon would be:

[filter]
type = Filter_external
path = /usr/local/bin/spamassassin
arguments = ("--report", )

The --report option sends the message to the various spam-blocker databases and tags it as spam in your bayesian database.

Note that if you are using Bayesian (learning) filtering, and you've put your SpamAssassin filter after any getmail Filter_classifier, you may have a problem with your learning filter learning getmail's header fields. That is, the headers added by the other filters may get learned, and affect your database. To prevent this, ensure that SpamAssassin ignores these fields by adding the following to your SpamAssassin configuration:

bayes_ignore_header X-getmail-filter-classifier

How do I use ClamAV with getmail?

You should also read this message in the getmail users' mailing list archives and the ClamAV documentation if you want to use ClamAV with getmail.

ClamAV, like SpamAssassin, can by used in standalone or client/server configurations. In either case, you need to add the StreamSaveToDisk option to your clamav.conf file to enable scanning from stdin.

To use ClamAV without the clamd daemon, use a filter configuration like this:

[filter]
type = Filter_classifier
path = /usr/local/bin/clamscan
arguments = ("--stdout", "--no-summary",
    "--mbox", "--infected", "-")
exitcodes_drop = (1,)

The above assumes you do not want the infected emails to be delivered. If you do want them delivered, you would use a slightly different configuration:

[filter]
type = Filter_classifier
path = /usr/local/bin/clamscan
arguments = ("--stdout", "--no-summary",
    "--mbox", "--infected", "-")
exitcodes_keep = (0,1)

To use ClamAV with the clamd daemon, use a filter configuration like this:

[filter]
type = Filter_classifier
path = /usr/local/bin/clamdscan
arguments = ("--stdout", "--disable-summary", "-")
exitcodes_drop = (1, )

As with Clamscan (above), if you do want the infected messages delivered instead of dropped, you should modify your configuration as follows:

[filter]
type = Filter_classifier
path = /usr/local/bin/clamdscan
arguments = ("--stdout", "--disable-summary", "-")
exitcodes_keep = (0,1)

You may find it necessary to specify the paths of some decompression utilities used by ClamAV with additional arguments like:

arguments = ( …,
    "--unzip=/usr/local/bin/unzip",
    "--unrar=/usr/local/bin/unrar",
    "--unarj=/usr/local/bin/unarj",
    "--lha=/usr/local/bin/lha",
    "--jar=/usr/local/bin/unzip",
    "--tar=/usr/bin/tar",
    "--tgz=/usr/bin/tar"

Note: if you want to use the daemonized (client/server) version of ClamAV, ensure that your clamav.conf file contains:

ScanMail

The paths to the various decompression utilities must be specified in this file as well.

Frankye Fattarelli had additional notes on using ClamAV with getmail in a message to the mailing list that was archived here: http://marc.theaimsgroup.com/?l=getmail&m=109128345509273&w=2 ... but that site is now dead, and I don't know what message it was. You can try finding it in the Gmane archive.

Getting prettier output from ClamAV

Using getmail's Filter_classifier, the output of your filtering program (in this case ClamAV) is placed into a X-getmail-filter-classifier: header field in the message. This can make auditing the actions of filters difficult if you use multiple filters and cannot tell which filter added which line.

To correct this, you can use an additional filter to change the name of the added filter header lines immediately after each filter is run. For example, reformail, from the maildrop package (which is in turn part of the Courier MTA ) can be used in this fashion to rename the added header fields (say, to "X-mypersonalmailscan") with a filter configuration like this:

type = Filter_external
path = /usr/local/bin/reformail
arguments = ("-R", "X-getmail-filter-classifier:",
    "X-mypersonalmailscan:")

Simply ensure ClamAV is invoked as the first filter, and this is invoked as the second filter (or immediately after the ClamAV filter, if it is the second, third, etc. filter).

How do I use F-Prot with getmail?

getmail user Kai Raven reports that getmail and F-Prot work fine together with the following getmailrc filter configuration:

[filter]
type = Filter_external
path = /usr/local/bin/f-prot-wrapper.sh

The wrapper script f-prot-wrapper.sh is a small shellscript by Ali Onur Cinar, and can be downloaded from his website.

How do I use procmail with getmail?

Simply invoke procmail as an external MDA. procmail requires that one of the following be true:

To have getmail generate and prepend the "From " line to the start of the message, set the MDA_external parameter unixfrom to True:

[destination]
type = MDA_external
path = /path/to/procmail
unixfrom = True

To supply the -f option to procmail, do something like this:

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

How do I use maildrop with getmail?

Simply invoke maildrop as an external MDA. maildrop requires that the message begin with a Unix "From " line (the mbox message delimiter), so you'll need to either set the MDA_external parameter unixfrom to True, or supply arguments that tell maildrop to recreate this line. One of the following would be fine:

[destination]
type = MDA_external
path = /path/to/maildrop
arguments = ("-f", "%(sender)")

Or:

[destination]
type = MDA_external
path = /path/to/maildrop
unixfrom = True

If you want to specify a maildrop rc file as one of its arguments, that would be something like:

[destination]
type = MDA_external
path = /path/to/maildrop
arguments = ("-f", "%(sender)", "~/.maildroprc")

How do I use TMDA with getmail?

Simply use the Filter_TMDA module as a message filter:

[filter-X]
type = Filter_TMDA

See the documentation for details on optional parameters to the Filter_TMDA module.

How can I get Gmail labels with getmail?

As of getmail version 4.34.0, getmail retrieves the labels and other metadata that Gmail makes available via an IMAP extension, and records that information in the message headers X-GMAIL-LABELS:, X-GMAIL-THRID:, and X-GMAIL-MSGID:.

I think I found this bug in getmail …

I get frequent reports like the following, which aren't bugs in getmail. Please read them before reporting them to me.

getmail doesn't download all my mail from Gmail …

There's a couple of different problems here. One is that Google's Gmail service violates the POP3 protocol by removing messages from the POP3 view of the mailbox without the user issuing a DELE command. They do this as soon as an RETR command is given, so if getmail tries to download a message and it fails for any reason (delivery fails due to a full disk, or the Gmail server fails to respond, or the network connection dies before the transfer is complete, or the Gmail server fails to respond to the QUIT command, or …), the next time getmail connects to that Gmail account, Gmail will have "helpfully" deleted the message from the POP3 mailbox, even though getmail never issued a DELE command. So Gmail silently destroys mail, from a POP3 perspective. There's nothing getmail can do about this.

Note this feature of Gmail is not well-publicized. The only mention I can find of it is here: http://mail.google.com/support/bin/answer.py?answer=13291&topic=1555

The other issue here is that Google doesn't include mail from your trash or spam folders in the POP3 view, so getmail can't see those messages either. That's generally less of an issue, provided their spam filters never give false positive results (ha!).

FutureWarning: %u/%o/%x/%X of negative int will return a signed string in Python 2.4 and up

Various people have reported this "bug" in getmail, where they see the following warning when getmail is run:

/usr/lib/python2.3/optparse.py:668: FutureWarning: %u/%o/%x/%X of negative int will return a signed string in Python 2.4 and up
  return ("<%s at 0x%x: %r>"

This warning is a bug in Python 2.3.4's optparse.py module, not in getmail. Feel free to report it to the Python team if the most recent release of Python hasn't fixed it. I reported it in June, 2004.

AttributeError: 'module' object has no attribute 'fsync'

Various people have reported this "bug" in getmail — it's actually a bug in some versions of Python 2.3.X. It was fixed in Python version 2.3.3. getmail 4 detects problematic versions of Python and refuses to run, but you can still encounter this problem with getmail version 3 if you try to run it with a broken Python version.

operation error (SimplePOP3Retriever: [...] does not uniquely identify messages [...] see documentation or use BrokenUIDLPOP3Retriever instead

The server you're trying to use does not properly uniquely identify messages (getmail noticed when it saw the same "unique" identifier twice in the same mailbox at the same time). getmail needs these identifiers to be unique so that it can properly tell the difference between new and old messages.

If you see this error message, and you've configured getmail to retrieve and immediately delete all messages, just switch to using the BrokenUIDLPOP3Retriever class (or its SSL variant) -- it'll work fine.

If you see this error message, and you're trying to leave messages on the server after retrieval (permanently, or for a few days with delete_after), you have a few options to try to resolve it:

MemoryError on OS X

If you see errors like this while running getmail on Macintosh OS X:

python2.5(27172) malloc: *** vm_allocate(size=15699968) failed (error code=3)
python2.5(27172) malloc: *** error: can't allocate region
python2.5(27172) malloc: *** set a breakpoint in szone_error to debug
[...]

... which then end with MemoryError, please report the problem to Apple. The OS X implementation of realloc() is broken, and there's nothing getmail can do about it.

MemoryError when using IMAP

If you see errors like this while running getmail configured to retrieve mail via IMAP or IMAP-over-SSL:

Python(24006) malloc: *** mmap(size=9875456) failed (error code=12)
[...]

... which then end with MemoryError, you've run into a bug in Python's IMAP library. It's fixed in the most recent versions of Python 2.5 and 2.6. This bug can cause getmail to grow to a huge size, vastly out of proportion to the size of the message it's retrieving, at which point Python may fail or be killed when the system runs out of memory.

Upgrade your Python installation to the newest Python 2.5 or 2.6 version to fix the problem, or use POP3 instead of IMAP to work around it.