                    getmail Frequently Asked Questions (FAQ)

   getmail6 is Copyright © 1998-2020 by Charles Cazabon and others:
   <charlesc-getmail @ pyropus.ca>
   <roland.puntaier @ gmail.com>

   getmail is licensed under the GNU General Public License version 2 (only).

                               Table of Contents

     * getmail documentation
     *    * getmail documentation
          *    * Features
               * Requirements
               * Obtaining getmail
               * Installing getmail
     * getmail configuration (version 5)
     *    * 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
          *    * Error messages
               * Warning messages
               * Unexpected Behaviour
     * getmail frequently-asked questions (FAQs)
     *    * Frequently-Asked Questions (FAQs)
          *    * About getmail
               *    * What is getmail?
                    * What is getmail6 and how does it relate to getmail?
                    * What platforms/machines does getmail run on?
                    *    * Does getmail run on MS Windows?
                         * Does getmail run on Macintosh systems?
                         * Does getmail require Unix/Linux?
                    * How can I get support for getmail?
                    * I think I found a bug! How do I report it?
                    * I have a neat idea for random feature "foo" … how do I
                      get you to implement it?
                    * Why won't you implement random feature "foo"?
                    * Does getmail support virus scanning of retrieved
                      messages?
                    * Does getmail support spam filtering of retrieved
                      messages?
                    * Does getmail support SSL?
                    * Does getmail rewrite mail headers when it retrieves
                      mail?
                    * What are these oldmail* files? Can I delete or trim
                      them?
                    * Can I upgrade from getmail 3 to getmail 4/5? What about
                      my "oldmail" files?
                    * Why did you write getmail? Why not just use fetchmail?
               * Configuring getmail
               *    * What is a "domain mailbox"?
                    * Do I have to run sendmail or another MTA to use
                      getmail?
                    * Will getmail deliver mail as root?
                    * What's a maildir?
                    * What's "mboxrd" format?
                    * What's this "envelope sender" and "envelope recipient"
                      stuff?
                    *    * Message header vs. message envelope
                         * Receiving messages without your address in the
                           message header
                         * Responsibility for recording the message envelope
                         * How this relates to domain or multidrop mailboxes
                    * This rc stuff seems complicated. Does it have to be?
               * How do I …
               *    * How do I retrieve mail from multiple accounts?
                    * How do I get getmail to deliver messages to different
                      mailboxes based on …
                    * How do I stop getmail adding a Delivered-To: header to
                      messages?
                    * How do I stop getmail adding a Received: header to
                      messages?
                    * How do I make getmail deliver messages by re-injecting
                      with SMTP?
                    * How do I create a maildir?
                    * How do I create an mboxrd file?
                    * How do I make getmail deliver messages to an mh folder?
                    * How do I run getmail in "daemon" mode?
                    * How do I make getmail stop after retrieving X messages
                      so that the server actually flushes deleted messages?
                    * How do I make getmail retrieve mail from Hotmail?
                    * I'm using getmail. How do I make it …
                    *    * I'm running getmail from cron. How do I
                           temporarily stop it?
                         * How do I stop multiple instances of getmail from
                           running at the same time?
               * Using getmail with other software
               *    * How do I use SpamAssassin with getmail?
                    * How do I use ClamAV with getmail?
                    *    * Getting prettier output from ClamAV
                    * How do I use F-Prot with getmail?
                    * How do I use procmail with getmail?
                    * How do I use maildrop with getmail?
                    * How do I use TMDA with getmail?
                    *    * How can I get Gmail labels with getmail?
               * I think I found this bug in getmail …
               *    * getmail doesn't download all my mail from Gmail …
                    * FutureWarning: %u/%o/%x/%X of negative int will return
                      a signed string in Python 2.4 and up
                    * AttributeError: 'module' object has no attribute
                      'fsync'
                    * operation error (SimplePOP3Retriever: [...] does not
                      uniquely identify messages [...] see documentation or
                      use BrokenUIDLPOP3Retriever instead
                    * MemoryError on OS X
                    * MemoryError when using IMAP
                    * Errors connecting to Gmail with OpenSSL 1.1.1

                       Frequently-Asked Questions (FAQs)

   The following questions about getmail have been asked 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 is getmail6 and how does it relate to getmail?

   getmail is the name of this software and project as it was originally
   developed by Charles Cazabon. At the time of getmail version 5.14 getmail
   would not work with Python version 3 and newer. As support for Python 3
   was not available for getmail at the time while many distributions were
   dropping support for all Python versions older than version 3, this fork
   was created.

   To avoid confusion and conflicts with Charles' project, we decided to call
   our fork getmail6 and start our version numbering from 6.

   As we intend getmail6 to be a drop-in replacement for getmail, names of
   files etc. have been kept the same as they are in getmail 5.14 and
   earlier.

  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:

     * Linux-based GNU systems (all distributions)
     * HURD-based GNU systems
     * FreeBSD
     * OpenBSD
     * NetBSD
     * HP/UX
     * Sun Solaris
     * IBM AIX
     * Digital/Compaq Tru64 (a.k.a OSF/1) UNIX
     * SGI Irix
     * other commercial Unices
     * Digital VMS / OpenVMS
     * BeOS
     * Amiga OS
     * OS/2
     * Cygwin on Windows
     * Macintosh OS X
     * Macintosh OS 9

   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, we
   will do our best to support getmail on a voluntary basis through our
   GitHub repository.

   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, please open an issue on GitHub. If you
   post your question there, we will see it.

  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://getmail6.org/.
   If you are running an older version of the software, chances are whatever
   bug you may have found has already been fixed.

   After this, please check our repository on GitHub to see if this issue has
   already been reported. If not, feel free to open an issue to report your
   bug. You should include at least the following information:

     * getmail version
     * Python version
     * any error message which getmail displayed
     * the output from running getmail with your normal options plus --dump
     * if your problem is getmail not determining the proper local recipient,
       please include the output of running getmail with your normal options
       plus --trace, showing the retrieval of one problematic message.

   If your bugreport contains confidential information, please exclude this
   from your report.

  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
   we would prefer you submit your idea as an issue in our repository
   allowing other users to also comment on it which may 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. We 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 us.

   If you have asked me to add some feature, and we've said no, this may be
   the reason. Other possibilities include us 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.

  What are these oldmail* files? Can I delete or trim them?

   getmail stores its state - its "memory" of what it has seen in your
   POP/IMAP account - in the oldmail files.

   Do NOT delete or edit these files. You'll make getmail re-retrieve all
   your old mail, or even prevent getmail from running. The files are tiny by
   modern storage standards; you could have a million of these files and
   still not have to worry about the disk space they take up for a thousand
   years.

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

   The below text is by Charles Cazabon, getmail's original author:

   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:

     * versions released before 20 June 2001 contain a buffer overflow, which
       can be remotely exploited (see www.securityfocus.com/bid/2877 for
       details). getmail is not vulnerable to buffer overflows, because
       buffers in Python are dynamically sized.
     * Another remotely-exploitable security hole discovered in fetchmail in
       June 2002; versions prior to 5.9.10 (released in June 2002) are
       exploitable .
     * Reading fetchmail's UPDATES file, it appears that another security
       problem was fixed in 5.9.12, where a server could crash fetchmail on
       64-bit platforms. Also worrying is a mention that it includes a fix
       for "password shrouding".
     * Another remotely-exploitable security hole in fetchmail discovered in
       September 2002; this hole lets an attacker run arbitrary code on the
       victim's computer.
     * Another remotely-exploitable security hole in fetchmail discovered in
       December 2002; once again, a remote attacker can run arbitrary code on
       the machine running fetchmail in its default configuration. See this
       advisory for details.
     * January 2003: More buffer overflows in fetchmail let attackers run
       arbitrary code .
     * October 2003: Anyone can cause fetchmail to crash by sending you a
       message . Other problems are here , and I might have missed some .
     * Just in case you thought fetchmail was all better now, there's still
       new security problems being discovered in it. In December, 2005, it
       was revealed that anyone can send a fetchmail multidrop user a message
       that causes fetchmail to crash.

   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:

     * another arbitrary code execution vulnerability announced on 21 July
       2005.

   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:

     * CVE-2005-4348 - anyone can crash fetchmail by sending messages without
       headers
     * CVE-2006-0321 - anyone can crash fetchmail by sending a message that
       fetchmail tries to bounce
     * CVE-2006-5867 - fetchmail can transmit passwords in plaintext even if
       the user has configured it not to
     * CVE-2006-5974 - anyone can cause fetchmail to crash by triggering
       certain error code paths

   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:

     * bcc'd messages (bcc stands for blind carbon copy), where you are an
       envelope recipient, but your address does not appear in the message
       content (i.e., your address does not appear in a To:, cc:, or similar
       message header field). With bcc'd messages, the From: header field
       contains the name and address of the author of the message, and the
       To: and cc: header fields contain the names and addresses of the
       other, non-blind recipients of the message.
     * mailing list messages, where you are an envelope recipient, but your
       address does not appear in the message content (i.e., your address
       does not appear in a To:, cc:, or similar message header field).
       Mailing list messages have the envelope sender address set to the
       mailing list manager (so that it can monitor "bad" list addresses for
       bounces), while the From: header field contains the name and address
       of the author of the message. The envelope recipient addresses of
       mailing list messages are the addresses of the list subscribers, while
       the To: header field usually contains the address of the mailing list.
     * other, less common cases.

   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?

   getmail does not have, and does not need, any special "daemon mode". You
   just run getmail under whatever process-supervision or periodic-job system
   you already have on your system.

   For example, if you use daemontools/svscan/supervise, you can configure a
   getmail "service" using a simple run script like:

 #!/bin/sh

 /path/to/getmail [options]
 sleep 1800

   That example would run getmail continuously, sleeping for 30 minutes
   between runs. You can probably work out similar scripts for other
   process-supervision systems.

   If you don't have such a system, you can use your system's cron utility to
   run getmail periodically, but you absolutely have to prevent multiple
   copies of getmail from being run by cron simultaneously. Most versions of
   cron have no protection for this built-in, so you have to use setlock or
   flock or a similar utility to prevent it. For more details, see How do I
   stop multiple instances of getmail from running at the same time? below.
   If you do not prevent multiple copies of getmail running against the same
   server (and IMAP folder) simultaneously, you will get odd behaviour,
   including retrieving the same messages multiple times.

  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 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; it will probably cause getmail to deliver
   duplicate copies of messages, "forget" that it has seen particular
   messages before, and other similar problems.

   In particular, if you're running getmail from a crontab, you must do
   something to prevent cron from starting getmail if the previous invocation
   is still running.

   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.

   See the following mailing list message from Frankye Fattarelli for
   additional notes on using ClamAV with getmail:
   https://marc.info/?l=getmail&m=109128345509273&w=2

    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:

     * that the message begin with a Unix "From " line (the mbox message
       delimiter)
     * that procmail is invoked with the -f option supplying the envelope
       sender, so that it may generate the "From " line

   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 …

   There are frequent reports like the following, which aren't bugs in
   getmail. Please read them before reporting them as bugs.

  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!).

  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:

     * If your provider also offers IMAP access to your mailbox, try one of
       the IMAP retrievers instead.
     * Change your configuration so you're not leaving messages on the
       server, and use BrokenUIDLPOP3Retriever instead.
     * Talk to your mail hosting provider, and see if they can fix their POP3
       software so that it doesn't have this problem any more.

  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.

  Errors connecting to Gmail with OpenSSL 1.1.1

   If you experience connection/SSL errors connecting to Gmail servers, and
   your OpenSSL is version 1.1.1 or higher, the problem is that Gmail is
   failing the connection on the basis that SNI is not in use. To work around
   the problem, upgrade to getmail v.5.10 or later, or tell getmail to use
   TLSv1.2 rather than TLS1.3 in your retriever configuration and specify TLS
   v1.2 as the protocol to use:

 [retriever]
 ...
 ssl_version = tlsv1_2
