FETCHMAIL(1)

๐Ÿ“ฆ
version 6.6.9 ยท 4 versions
, in arch rolling

๐Ÿ’Œ FETCHMAIL(1) โ€” the fetchmail reference manual, bestie edition ๐Ÿ’Œ

okay so. this is the manual page for fetchmail (section 1 of the manual, if you're keeping track). it's long. it's iconic. grab a snack. ๐Ÿ“


โœจ NAME โœจ

fetchmail โ€” go grab your mail from a POP, IMAP, ETRN, or ODMR-capable server. that's it, that's the job. ๐Ÿ’…


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

fetchmail [option...] [mailserver...]
fetchmailconf

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so like, fetchmail is a mail-retrieval and forwarding utility โ€” it fetches mail from remote mail servers and forwards it to your local (client) machine's delivery system. then you just... handle the mail with normal mail user agents like mutt(1), elm(1) or Mail(1). casual. โœจ

and get this โ€” fetchmail can run in daemon mode to repeatedly poll one or more systems at a specified interval. it just keeps checking. obsessed. ๐Ÿ˜Œ

the fetchmail program can gather mail from servers supporting any of the common mail-retrieval protocols:

  • POP2 (legacy, to be removed from future release ๐Ÿ’€)
  • POP3
  • IMAP2bis
  • IMAP4
  • IMAP4rev1

it can also use the ESMTP ETRN extension and ODMR. (all the RFCs describing these protocols are listed at the end of this manual page, we'll get there.)

and while fetchmail is primarily meant to be used over on-demand TCP/IP links (think SLIP or PPP connections), it may also be useful as a message transfer agent for sites that refuse โ€” for security reasons โ€” to permit (sender-initiated) SMTP transactions with sendmail.


๐Ÿ” DEPRECATION AND CRYPTOGRAPHIC SECURITY WARNINGS ๐Ÿ”

okay bestie, this part is important, listen up. several cryptographic algorithms that are referenced by mail standards for authentication were based on MD4, MD5 or SHA1 algorithms that were developed in 1990, 1991 and 1995 respectively. 30 years later? these are no longer deemed secure. they are considered broken. ๐Ÿ’€

not all IETF standards and RFCs have given up on them, and some protocols actively require something that incorporates MD4, MD5 or SHA1 in some form โ€” so disabling their use in fetchmail altogether would also pull the plug on, say, protocols such as ODMR, or formerly-popular authentication schemes such as POP3 with APOP.

the recommendation is: prefer TLS-wrapped connections via dedicated ports 993 (IMAP4) or 995 (POP3), or STARTTLS in-band negotiation with such authentication schemes, to reduce the risk to expose login credentials. ๐Ÿซถ

also, weak authentication schemes will be phased out from future fetchmail releases. please see the NEWS file that should have come with your distribution of fetchmail.


๐Ÿ› ๏ธ SUPPORT, TROUBLESHOOTING ๐Ÿ› ๏ธ

for troubleshooting, tracing and debugging, you need to increase fetchmail's verbosity to actually see what happens. to do that, please run both of the two following commands, adding all of the options you'd normally use.

env LC_ALL=C fetchmail -V -v --nodetach --nosyslog

(this command line prints in English how fetchmail understands your configuration.)

env LC_ALL=C fetchmail -vvv  --nodetach --nosyslog

(this command line actually runs fetchmail with verbose English output.)

also see item #G3 in fetchmail's FAQ.

you can omit the LC_ALL=C part above if you want output in the local language (if supported). however if you are posting to mailing lists, please leave it in. the maintainers do not necessarily understand your language, please use English. ๐Ÿ™ˆ


๐ŸŽ€ QUICKSTART ๐ŸŽ€

  1. set up a local SMTP mail server, or a command-line based mail delivery agent such as maildrop or dovecot-lda, configure and test and debug it. make sure that mail you deliver to yourself through it ends up in the right place.
Do NOT continue unless and until this works or you risk losing mail! ๐Ÿ˜ญ
  1. create a .fetchmailrc file in your home directory that looks roughly like this, for POP3 fetches.
poll mailserver.example.org proto POP3 uidl
user joe.sixpack
keep ssl

you need to adjust several elements here: mailserver.example.org is the server's name. joe.sixpack is the login name to use for the server. keep states that messages should be left on the server, rather than deleted. ssl states that the connection should be encrypted. if you need to use IMAP instead of POP3, change proto POP3 uidl to proto IMAP.

if you chose to deliver through a command-line program, add an mda option, for instance:

mda "/usr/bin/maildrop -d %T"
  1. and then make sure the ~/.fetchmailrc file is not readable or writable to anyone but yourself:
chmod 0600 ~/.fetchmailrc
  1. finally, run fetchmail in verbose mode and see that it works. to limit impact, if something goes wrong, we just try two messages:
fetchmail -v --fetchlimit 2

if then the POP3 server refuses UIDL, you cannot use the keep option on that server and you need to remove the uidl and keep options โ€” but note that then fetchmail will remove messages it has successfully delivered from the server. ๐Ÿซฃ


๐ŸŒธ TLS (SSL) QUICKSTART ๐ŸŒธ

your fetchmail distribution should have come with a README.SSL file, which see. it is recommended to configure all polls with --ssl --sslproto tls1.2+ if supported by the server, which configures fetchmail along recent IETF proposed standards and best current practices, RFC-8314, RFC-8996, RFC-8997. โœจ

Fetchmail 6.6.0 and newer also support TLS and STARTTLS for SMTP, see the --smtphost option for how to configure those.


๐Ÿ’ญ CONCEPTS ๐Ÿ’ญ

if fetchmail is used with a POP or an IMAP server (but not with ETRN or ODMR), it has two fundamental modes of operation for each user account from which it retrieves mail: singledrop- and multidrop-mode.

๐Ÿ“ฌ In singledrop-mode

fetchmail assumes that all messages in the user's account (mailbox) are intended for a single recipient. the identity of the recipient will either default to the local user currently executing fetchmail, or will need to be explicitly specified in the configuration file.

fetchmail uses singledrop-mode when the fetchmailrc configuration contains at most a single local user specification for a given server account.

๐Ÿ‘‘ In multidrop-mode

fetchmail assumes that the mail server account actually contains mail intended for any number of different recipients. therefore, fetchmail must attempt to deduce the proper "envelope recipient" from the mail headers of each message. in this mode of operation, fetchmail almost resembles a mail transfer agent (MTA).

note that neither the POP nor IMAP protocols were intended for use in this fashion, and hence envelope information is often not directly available. the ISP must store the envelope information in some message header. the ISP must also store one copy of the message per recipient. if either one of the conditions is not fulfilled, this process is unreliable, because fetchmail must then resort to guessing the true envelope recipient(s) of a message. this usually fails for mailing list messages and Bcc:d mail, or mail for multiple recipients in your domain. ๐Ÿ˜ฌ

fetchmail uses multidrop-mode when more than one local user and/or a wildcard is specified for a particular server account in the configuration file.

โšก In ETRN and ODMR modes

these considerations do not apply, as these protocols are based on SMTP, which provides explicit envelope recipient information. these protocols always support multiple recipients. slay.


as each message is retrieved, fetchmail normally delivers it via SMTP to port 25 on the machine it is running on (localhost), just as though it were being passed in over a normal TCP/IP link. fetchmail provides the SMTP server with an envelope recipient derived in the manner described previously. the mail will then be delivered according to your MTA's rules (the Mail Transfer Agent is usually sendmail(8), exim(8), or postfix(8)). invoking your system's MDA (Mail Delivery Agent) is the duty of your MTA. all the delivery-control mechanisms (such as .forward files) normally available through your system MTA and local delivery agents will therefore be applied as usual. ๐Ÿซถ

if your fetchmail configuration sets a local MDA (see the --mda option), it will be used directly instead of talking SMTP to port 25.

if the program fetchmailconf is available, it will assist you in setting up and editing a fetchmailrc configuration. it runs under the X window system and requires that the language Python and the Tk toolkit (with Python bindings) be present on your system. if you are first setting up fetchmail for single-user mode, it is recommended that you use Novice mode. Expert mode provides complete control of fetchmail configuration, including the multidrop features. in either case, the 'Autoprobe' button will tell you the most capable protocol a given mail server supports, and warn you of potential problems with that server. โœจ


๐Ÿ“– PREFACE ON THIS MANUAL ๐Ÿ“–

fetchmail's run-time strings have been translated (localized) to some languages, but the manual is only available in English. in some situations, for comparing output to manual, it may be helpful to switch fetchmail to English output by overriding the locale variables, for instance:

env LC_ALL=C fetchmail # add other options before the hash
env LANG=en fetchmail # other options before the hash

or similar. details vary by operating system.


โš™๏ธ GENERAL OPERATION โš™๏ธ

the behavior of fetchmail is controlled by command-line options and a run control file, ~/.fetchmailrc, the syntax of which we describe in a later section (this file is what the fetchmailconf program edits). command-line options override ~/.fetchmailrc declarations. ๐Ÿ‘‘

each server name that you specify following the options on the command line will be queried. if you do not specify any servers on the command line, each 'poll' entry in your ~/.fetchmailrc file will be queried, unless the idle option is used, which see.

to facilitate the use of fetchmail in scripts and pipelines, it returns an appropriate exit code upon termination โ€” see EXIT CODES below.

the following options modify the behavior of fetchmail. it is seldom necessary to specify any of these once you have a working .fetchmailrc file set up.

almost all options have a corresponding keyword which can be used to declare them in a .fetchmailrc file.

some special options are not covered here, but are documented instead in sections on AUTHENTICATION and DAEMON MODE which follow.


๐Ÿ’… General Options ๐Ÿ’…

  • -? | --help โ€” displays option help. that's it bestie, it just tells you the options. ๐Ÿ™ˆ
  • -V | --version โ€” displays the version information for your copy of fetchmail. no mail fetch is performed. instead, for each server specified, all the option information that would be computed if fetchmail were connecting to that server is displayed. any non-printable characters in passwords or other string names are shown as back-slashed C-like escape sequences. this option is useful for verifying that your options are set the way you want them. โœ…
  • -c | --check โ€” gives you a status code that says "bestie, there's mail waiting" without actually fetching or deleting anything (peep EXIT CODES down below ๐Ÿ‘‡). Heads up: this option turns off daemon mode, because in daemon mode it would be straight-up useless. It also does not play nice with queries to multiple sites, and it refuses to work with ETRN or ODMR. And here's the tea: it'll hand you a false positive if you leave read-but-undeleted mail sitting in your server mailbox and your fetch protocol can't tell kept messages apart from new ones. Translation: it works with IMAP, does not work with POP2, and may occasionally flake out under POP3. ๐Ÿ˜ญ
  • -s | --silent โ€” silent mode, the "don't talk to me rn" setting. It suppresses all those progress/status messages that normally get echoed to standard output during a fetch (but it does not suppress actual error messages, because errors are important, bestie). The --verbose option overrides this.
  • -v | --verbose โ€” verbose mode, aka main character energy. Every control message passed between fetchmail and the mail server gets echoed to stdout. Overrides --silent. Double it up (-v -v) and you get extra diagnostic info printed. Obsessed. ๐Ÿ’…
  • --nosoftbounce โ€” (since v6.3.10, Keyword: set no softbounce, since v6.3.10) Hard bounce mode. All permanent delivery errors cause messages to be deleted from the upstream server โ€” see "no softbounce" below. ๐Ÿ’€
  • --softbounce โ€” (since v6.3.10, Keyword: set softbounce, since v6.3.10) Soft bounce mode. All permanent delivery errors cause messages to be left on the upstream server, if the protocol supports that. This option is on by default to match historic fetchmail documentation, and it will be changed to hard bounce mode in the next fetchmail release. So like, heads up, the default is getting a glow-up later.

๐ŸŒธ Disposal Options ๐ŸŒธ

  • -a | --all | --fetchall (this last one since v6.3.3) โ€” (Keyword: fetchall, since v3.0) Retrieve both old (seen) and new messages from the mail server. The default? Only fetch what the server hasn't marked seen. Under POP3, this option also forces the use of RETR instead of TOP. Ngl, note that POP2 retrieval acts like --all is permanently on (check RETRIEVAL FAILURE MODES below), and this option does not work with ETRN or ODMR. And for the lore: -a and --all on the command line plus the fetchall rcfile option have been supported forever, but the --fetchall command-line option only showed up in v6.3.3. โœจ
  • -k | --keep โ€” (Keyword: keep) Keeps retrieved messages on the remote mail server. Normally messages get deleted from the folder on the mail server once they've been retrieved. Saying keep makes retrieved messages stay in your folder on the mail server instead. Just so you know: this option does not work with ETRN or ODMR. And if you use it with POP3, it's recommended you also specify the --uidl option or the uidl keyword. ๐Ÿซถ
  • -K | --nokeep โ€” (Keyword: nokeep) Deletes retrieved messages from the remote mail server. This one forces retrieved mail to be deleted, which is mad useful if you set a default of keep in your .fetchmailrc. This option is forced on with ETRN and ODMR.
  • --moveto <folder> โ€” (Keyword: moveto) In IMAP mode, instead of flushing a message, move it to the given IMAP folder. This slays for avoiding data loss while testing, and it's the preferred way to delete emails on certain implementations โ€” for example, Google wants you to delete mails by moving them to [Gmail]/Trash. Only available for IMAP servers. This option is only accepted with --proto imap, but not if IMAP is chosen automatically. It's ineffective when --keep is in effect. ๐Ÿ™ˆ
  • -F | --flush โ€” (Keyword: flush) POP3/IMAP only. This is a dangerous option and can cause mail loss when used improperly. It deletes old (seen) messages from the mail server before retrieving new messages.
โš ๏ธ Warning, bestie, fr fr: this can cause mail loss if you check your mail with other clients besides fetchmail, and it can make fetchmail delete a message it had never fetched before. It can also cause mail loss if the mail server marks the message seen after retrieval (IMAP2 servers). You should probably not use this option in your configuration file. If you use it with POP3, you must use the uidl option. What you probably want is the default setting: if you don't specify -k, then fetchmail will automatically delete messages after successful delivery.
  • --limitflush โ€” POP3/IMAP only, since version 6.3.0. Deletes oversized messages from the mail server before retrieving new messages. The size limit should be separately specified with the --limit option. Also, this option does not work with ETRN or ODMR.

๐Ÿฆ‹ Protocol and Query Options ๐Ÿฆ‹

  • -p <proto> | --proto <proto> | --protocol <proto> โ€” (Keyword: proto[col]) Tells fetchmail which protocol to use when talking to the remote mail server. If you don't specify one, the default is AUTO. Your proto can be one of these iconic picks:
    • AUTO โ€” tries IMAP, POP3, and POP2 (skipping any of these for which support hasn't been compiled in).
    • POP2 โ€” Post Office Protocol 2 (legacy, slated to be removed from a future release).
    • POP3 โ€” Post Office Protocol 3.
    • APOP โ€” use POP3 with old-fashioned MD5-challenge authentication. Considered not resistant to man-in-the-middle attacks. ๐Ÿ˜ฌ
    • RPOP โ€” use POP3 with RPOP authentication.
    • KPOP โ€” use POP3 with Kerberos V4 authentication on port 1109.
    • SDPS โ€” use POP3 with Demon Internet's SDPS extensions.
    • IMAP โ€” IMAP2bis, IMAP4, or IMAP4rev1 (fetchmail automatically detects their capabilities).
    • ETRN โ€” use the ESMTP ETRN option.
    • ODMR โ€” use the On-Demand Mail Relay ESMTP profile.

All these alternatives work basically the same way (communicating with standard server daemons to fetch mail already delivered to a mailbox on the server) โ€” except ETRN and ODMR. The ETRN mode lets you ask a compliant ESMTP server (like BSD sendmail at release 8.8.0 or higher) to immediately open a sender-SMTP connection to your client machine and start forwarding any items addressed to your client machine that are sitting in the server's queue of undelivered mail. The ODMR mode needs an ODMR-capable server and works similarly to ETRN, except it does not require the client machine to have a static DNS. ๐ŸŒˆ

  • -U | --uidl โ€” (Keyword: uidl) Forces UIDL use (only effective with POP3). It forces client-side tracking of the 'newness' of messages (UIDL stands for "unique ID listing" and is described in RFC1939). Use it with keep to use a mailbox as a baby news drop for a group of users. The fact that seen messages get skipped is logged, unless error logging goes through syslog while running in daemon mode. Note that fetchmail may automatically enable this option depending on upstream server capabilities. Also note this option may be removed and forced enabled in a future fetchmail version. See also: --idfile.
  • --idle (since 6.3.3) โ€” (Keyword: idle, since before 6.0.0) Enables IDLE use (only effective with IMAP). Careful, bestie: this works with only one account and one folder at a given time โ€” other folders or accounts will not be polled when idle is in effect! While the idle rcfile keyword has been supported for a long time, the --idle command-line option only showed up in version 6.3.3. IDLE use means fetchmail tells the IMAP server to send notice of new messages, so they can be retrieved sooner than regular polls would allow. Fetchmail also contains a workaround to emulate IDLE; this workaround was ineffective since 6.4.22 and fixed in 6.5.3 (broken by commit 616e8c70 and repaired in f91923b5), Gitlab issue #69. ๐Ÿ’€
  • --forceidle (since 6.5.0) โ€” (Keyword: forceidle, since 6.5.0) Use IDLE even if the server doesn't advertise it in its capabilities. This is a dangerous option, use carefully. โš ๏ธ
  • --idletimeout (since 6.5.0) โ€” (Keyword: idletimeout, since 6.5.0) Sets the timeout (in seconds) for the IDLE command, because way too many servers break the protocol (which requires 30 minutes) and hang up after a few minutes. Default value: 1680 s (= 28 min).
  • -P <portnumber> | --service <servicename> โ€” (Keyword: service) Since version 6.3.0. The service option lets you specify a service name to connect to. You can put a decimal port number here instead, if your services database is missing the required service-port assignments. See the FAQ item R12 and the --ssl documentation for details. This replaces the older --port option.

Just so you know: this does not magically switch between TLS-wrapped and STARTTLS modes. If you specify a port number or service name here that is TLS-wrapped โ€” meaning it starts negotiating TLS before sending application data in the clear โ€” you may need to specify --ssl on the command line or ssl in your rcfile. ๐ŸŽ€

  • --port <portnumber> โ€” (Keyword: port) The obsolete version of --service that doesn't take service names. Note: this option may be removed from a future version.
  • --principal <principal> โ€” (Keyword: principal) The principal option lets you specify a service principal for mutual authentication. This applies to POP3 or IMAP with Kerberos 4 authentication only. It does not apply to Kerberos 5 or GSSAPI. This option may be removed in a future fetchmail version.
  • -t <seconds> | --timeout <seconds> โ€” (Keyword: timeout) The timeout option lets you set a server-non-response timeout in seconds. If a mail server doesn't send a greeting message or respond to commands for the given number of seconds, fetchmail will drop the connection to it. Without such a timeout, fetchmail might just hang until the TCP connection times out, trying to fetch mail from a down host โ€” which may take very long. That would be particularly annoying for a fetchmail running in the background. There's a default timeout which fetchmail -V will report. If a given connection receives too many timeouts in succession, fetchmail will consider it wedged and stop retrying. The calling user will be notified by email if this happens. ๐Ÿ“ง

okay so beginning with fetchmail 6.3.10, the SMTP client literally uses the recommended minimum timeouts from RFC-5321 while it's sitting there waiting on the SMTP/LMTP server it's talking to. ๐Ÿ’…

you can raise those timeouts even more if you want, bestie, but you cannot shorten them. and there's a whole reason for that: it's to avoid a painful situation where fetchmail has been configured with a short timeout (a minute or less), ships a long message (many MBytes) to the local MTA, which then takes longer than timeout to respond "OK", which it eventually will; that would mean the mail gets delivered properly, but fetchmail cannot notice it and will thus re-fetch this big message over and over again. ๐Ÿ˜ญ like. the drama. the waste.


  • --plugin <command> โ€” (Keyword: plugin)

The plugin option lets you use an external program to establish the TCP connection. super useful if you wanna use ssh, or you need some special firewall setup. ๐ŸŒˆ

The program will be looked up in $PATH and can optionally be passed the host name and port as arguments using "%h" and "%p" respectively (note that the interpolation logic is rather primitive, and these tokens must be bounded by whitespace or beginning of string or end of string). Fetchmail will write to the plugin's stdin and read from the plugin's stdout. ๐Ÿซถ

  • --plugout <command> โ€” (Keyword: plugout)

Identical to the plugin option above, but this one is used for the SMTP connections. same energy, different socket. โœจ

  • -r <name> | --folder <name> โ€” (Keyword: folder[s])

Causes a specified non-default mail folder on the mail server (or comma-separated list of folders) to be retrieved. The syntax of the folder name is server-dependent. This option is not available under POP3, ETRN, or ODMR. ๐Ÿšซ

  • --tracepolls โ€” (Keyword: tracepolls)

Tell fetchmail to poll trace information in the form 'polling account %s' and 'folder %s' to the Received line it generates, where the %s parts are replaced by the user's remote name, the poll label, and the folder (mailbox) where available (the Received header also normally includes the server's true name). This can be used to facilitate mail filtering based on the account it is being received from. The folder information is written only since version 6.3.4. ๐ŸŽ€

  • --ssl โ€” (Keyword: ssl)

Causes the connection to the mail server to be encrypted via SSL, by negotiating SSL directly after connecting (called SSL-wrapped mode, or Implicit TLS by RFC-8314). Please see the description of --sslproto below! More information is available in the README.SSL file that ships with fetchmail. ๐Ÿ”

Note that even if this option is omitted, fetchmail may still negotiate SSL in-band for POP3 or IMAP, through the STLS or STARTTLS feature. You can use the --sslproto option to modify that behavior.

If no port is specified, the connection is attempted to the well known port of the SSL version of the base protocol. This is generally a different port than the port used by the base protocol. For IMAP, this is port 143 for the clear protocol and port 993 for the SSL secured protocol; for POP3, it is port 110 for the clear text and port 995 for the encrypted variant.

If your system lacks the corresponding entries from /etc/services, see the --service option and specify the numeric port number as given in the previous paragraph (unless your ISP had directed you to different ports, which is uncommon however).

  • --nossl โ€” (Keyword: nossl)

Cancels out a default of ssl given earlier, in defaults, or in an rcfile if --nossl is given on the command-line. Use --sslproto with proper argument to enable STARTTLS. ๐Ÿ’…

  • --sslcert <name> โ€” (Keyword: sslcert)

For certificate-based client authentication. Some SSL encrypted servers require client side keys and certificates for authentication. In most cases, this is optional. This specifies the location of the public key certificate to be presented to the server at the time the SSL session is established. It is not required (but may be provided) if the server does not require it. It may be the same file as the private key (combined key and certificate file) but this is not recommended. Also see --sslkey below. ๐Ÿ”‘

NOTE: If you use client authentication, the user name is fetched from the certificate's CommonName and overrides the name set with --user. ๐Ÿ˜ณ
  • --sslkey <name> โ€” (Keyword: sslkey)

Specifies the file name of the client side private SSL key. Some SSL encrypted servers require client side keys and certificates for authentication. In most cases, this is optional. This specifies the location of the private key used to sign transactions with the server at the time the SSL session is established. It is not required (but may be provided) if the server does not require it. It may be the same file as the public key (combined key and certificate file) but this is not recommended.

If a password is required to unlock the key, it will be prompted for at the time just prior to establishing the session to the server. This can cause some complications in daemon mode. ๐Ÿ™ˆ

Also see --sslcert above.

  • --sslproto <value> โ€” (Keyword: sslproto, NOTE: semantic changes since v6.4.0)

This option has a dual use, out of historic fetchmail behaviour. It controls both the SSL/TLS protocol version and, if --ssl is not specified, the STARTTLS behaviour (upgrading the protocol to an SSL or TLS connection in-band). Some other options may however make TLS mandatory โ€” in particular, --sslcertck is now default behavior and requires SSL.

Recognized values for --sslproto are given below. You should normally choose one of the auto-negotiating options, i. e. 'tls1.2+' or 'auto' or one of the other options ending in a plus (+) character. Note that depending on the TLS library (OpenSSL, AWS-LC, wolfSSL) version and configuration, some options cause run-time errors because the requested SSL or TLS versions are not supported by the particular installed TLS library. Be sure to test well before you deploy for unattended operation! ๐Ÿ”ฅ

  • 'auto' (default, the same as TLS1.2+). Since v6.4.0, changed in v6.5.0. Require TLS. Auto-negotiate TLSv1.2 or newer, disable downgrade below. (older fetchmail versions than v6.5.0 have auto-negotiated older protocols, v6.4.x would permit TLSv1.0 by default, v6.3.x would permit SSLv3).
  • '', the empty string โ€” Disable STARTTLS. If --ssl is given for the same server, log an error and pretend that 'auto' had been used instead.
  • 'SSL23' โ€” see 'auto'. Deprecated, recognized for backwards compatibility.
  • 'TLS' โ€” see 'auto'. For symmetry with OpenSSL client method names.
  • 'TLS1' โ€” Require TLSv1. This does not negotiate TLSv1.1 or newer, and is discouraged. Replace by TLS1+ unless the latter chokes your server.
  • 'TLS1+' โ€” Since v6.4.0. This is an auto-negotiation feature that will permit TLSv1.0 and newer.
  • 'TLS1.1' โ€” Since v6.4.0. Require TLS v1.1 exactly.
  • 'TLS1.1+' โ€” Since v6.4.0. Require TLS. Auto-negotiate TLSv1.1 or newer.
  • 'TLS1.2' โ€” Since v6.4.0. Require TLS v1.2 exactly.
  • 'TLS1.2+' โ€” Since v6.4.0. Require TLS. Auto-negotiate TLSv1.2 or newer. This is the default in fetchmail v6.5.x. ๐Ÿ‘‘
  • 'TLS1.3' โ€” Since v6.4.0. Require TLS v1.3 exactly.
  • 'TLS1.3+' โ€” Since v6.4.0. Require TLS. Auto-negotiate TLSv1.3 or newer.
  • Unrecognized parameters โ€” are treated the same as 'auto'.
NOTE: you should hardly ever need to use anything other than '' (to force an unencrypted connection) or 'auto' (to enforce TLS). fr fr.
  • --sslcertck โ€” (Keyword: sslcertck, default enabled since v6.4.0)

--sslcertck causes fetchmail to require that SSL/TLS be used and disconnect unless it can successfully negotiate SSL or TLS, or if it cannot successfully verify and validate the certificate and follow it to a trust anchor (or trusted root certificate). The trust anchors are given as a set of local trusted certificates (see the sslcertfile and sslcertpath options). If the server certificate cannot be obtained or is not signed by one of the trusted ones (directly or indirectly), fetchmail will disconnect, regardless of the sslfingerprint option. ๐Ÿ›ก๏ธ

  • --nosslcertck โ€” (Keyword: no sslcertck, only in v6.4.X)

The opposite of --sslcertck, this is a discouraged option. It permits fetchmail to continue connecting even if the server certificate failed the verification checks. Should only be used together with --sslfingerprint. ๐Ÿ’€

  • --sslcertfile <file> โ€” (Keyword: sslcertfile, since v6.3.17)

Sets the file fetchmail uses to look up local certificates. The default is empty. This can be given in addition to --sslcertpath below, and certificates specified in --sslcertfile will be processed before those in --sslcertpath. The option can be used in addition to --sslcertpath.

The file is a text file. It contains the concatenation of trusted CA certificates in PEM format.

Note that using this option will suppress loading the default SSL trusted CA certificates file unless you set the environment variable FETCHMAIL_INCLUDE_DEFAULT_X509_CA_CERTS to a non-empty value. โš ๏ธ
  • --sslcertpath <directory> โ€” (Keyword: sslcertpath)

Sets the directory fetchmail uses to look up local certificates. The default is your OpenSSL default directory. The directory must be hashed the way OpenSSL expects it โ€” every time you add or modify a certificate in the directory, you need to use the c_rehash tool (which comes with OpenSSL in the tools/ sub-directory). Also, after OpenSSL upgrades, you may need to run c_rehash. ๐ŸŒ€

This can be given in addition to --sslcertfile above, which see for precedence rules.

Note that using this option will suppress adding the default SSL trusted CA certificates directory unless you set the environment variable FETCHMAIL_INCLUDE_DEFAULT_X509_CA_CERTS to a non-empty value. So yeah, if you want your defaults and your custom path, set that env var to literally anything, bestie. ๐Ÿ’…

  • --sslcommonname <common name> โ€” (Keyword: sslcommonname; since v6.3.9)

Bestie, using this option is discouraged. Lowkey it's a "please fix your server first" situation. Before you even touch it: message the admin of your upstream server and ask them for a proper SSL certificate. ๐Ÿ™

If that literally cannot happen (rip), this option lets you specify the name (CommonName) that fetchmail expects on the server certificate. A correctly configured server will have this set to the host name by which it is reached, and by default fetchmail will expect as much. Use this option when the CommonName is set to some other value, to avoid the "Server CommonName mismatch" warning โ€” and only if the upstream server's operator cannot be made to use proper certificates. ๐Ÿซ 

  • --sslfingerprint [{<algo>}]<fingerprint> โ€” (Keyword: sslfingerprint)

Specify the fingerprint of the server key in hexadecimal notation with colons separating groups of two digits. This is the format that fetchmail uses to report the fingerprint when an SSL connection is established. When this is specified, fetchmail will compare the server key fingerprint with the given one, and the connection will fail if they do not match, regardless of the sslcertck setting. The connection will also fail if fetchmail cannot obtain an SSL certificate from the server. This can be used to prevent man-in-the-middle attacks, but the fingerprint from the server must be obtained or verified over a secure channel, and certainly not over the same Internet connection that fetchmail would use. ๐Ÿšจ

The fingerprint can be prefixed with an EVP_MD digest algorithm name in curly braces, for instance, {MD5}00:01:...:0F. All digest algorithms that your SSL provider library supports can be used. Choose a sensible one, for instance, SHA256. If the {algo} prefix is omitted, MD5 is used for compatibility with fetchmail 6.4 and older.

Using this option will prevent printing certificate verification errors as long as --nosslcertck is in effect.

If you just want the --verbose log output to switch logging to a different hash, without pinning the server's certificate hash, you can use --sslfingerprint '{algo}*', f.i., --sslfingerprint '{SHA256}*'

To obtain the fingerprint of a certificate stored in the file cert.pem, try:

openssl x509 -in cert.pem -noout -sha256 -fingerprint

For details, see x509(1ssl).


๐Ÿšš Delivery Control Options ๐Ÿ’Œ

  • -S <hosts> | --smtphost <hosts> โ€” (Keyword: smtp[host])
    • (since v6.6.0, fetchmail supports TLS and STARTTLS for SMTP hosts)
    • (since v6.5.6, fetchmail knows how to generate RFC-5321 IP address literals from a bare numeric-address IPv4 or IPv6 string)

Specify a hunt list of hosts to forward mail to (one or more host names, comma-separated). Hosts are tried in list order; the first one that is up becomes the forwarding target for the current run. If this option is not specified, 'localhost' is used as the default. Each host name may have a port number following the host name. The port number is separated from the host name by a slash; the default port is "smtp". If you specify an absolute path name (beginning with a /), it will be interpreted as the name of a UNIX socket accepting LMTP connections (such as is supported by the Cyrus IMAP daemon). โœจ

Example:

--smtphost server1,server2/2525,server3,/var/imap/socket/lmtp

This option can be used with ODMR, and will make fetchmail a relay between the ODMR server and SMTP or LMTP receiver.

Each host name for SMTP servers supports up to four options separated with a slash (/):

  • /25 or /587 or /smtp or /465 or /smtps โ€” 25 or any other number between 1 and 65535 designates the port number to connect to; smtp or any other service name that the system can resolve (simple setups may use /etc/services); if not given, fetchmail will use default port numbers as described below. ๐Ÿงš

One of:

  • /notls โ€” disables opportunistic STARTTLS even if offered by the server. This is implied if the hostname is localhost exactly.
  • /starttls โ€” requires the server to offer STARTTLS in the Extended Hello (EHLO) and requires that the server certificate validates as if --sslcertck had been set. The default port will be 25.
  • /tls โ€” negotiates TLS wrapping before exchanging the greeting and requires that the server certificate validates as if --sslcertck had been set. The default port will be 465.

None of /notls, /tls, /starttls:

  • opportunistic TLS (except for localhost, see above). Will try to negotiate STARTTLS if offered by the server, but will not insist on certificate validation, as if by --nosslcertck.
  • /tlsproto=PROTO โ€” behaves as though --sslproto PROTO had been given, which see. Ignored if /notls is active.
  • /servername=NAME โ€” switches the expected X.509 certificate name to NAME and will pass it through Server Name Indication (SNI) if the SMTP service multiplexes by server name. Ignored if /notls is active.
NOTE 1: any text not recognized explicitly will be considered a service name; syntax errors such as mistyped options can show up as confusing getaddrinfo() errors to resolve a service, for instance, as 'Servname not supported for ai_socktype'. ๐Ÿ’€
NOTE 2: when contradictory options are given, the last one given prevails. No cap.

Example:

--smtphost dnsname.example.org/25/starttls/tlsproto=tls1.3/servername=commonname.example.com

would resolve dnsname.example.org, connect to it on port 25, try to issue an STARTTLS command and upgrade to TLS v1.3 and expect that the server's X.509 certificate matches the name commonname.example.com. Slay. ๐Ÿ‘‘

WARNING for versions 6.5.5 and before: if you use address numeric IP addresses here, be sure to use --smtpaddress or --smtpname (either of which see) with a valid SMTP address literal! โš ๏ธ
  • --esmtpname <authid> โ€” (since v6.5.7; Keyword: esmtpname, since v5.9.9)

Sets the authorization ID for SMTP AUTH to be used for logging into the SMTP server. Defaults to fetchmail's notion of the running user, taken from the first defined environment variable FETCHMAILUSER, LOGNAME, USER. (not currently listed in --help output)

NOTE: This is per "poll" and will be the same for all servers listed in your smtphost list! ๐Ÿ™ˆ
NOTE: fetchmail does not currently enforce that the connection goes via loopback interface or TLS secured encrypted layer โ€” be sure to enforce TLS or STARTTLS on the SMTP server if it's not your localhost. ๐Ÿ”’
  • --esmtppassword <secret> โ€” (since v6.5.7; Keyword: esmtppassword, since v5.9.9)

Sets the secret/password for SMTP AUTH to be used for logging into the SMTP server. (not currently listed in --help output)

NOTE 1: instead of in fetchmail's rcfile, you can put the password into the which see.
NOTE 2: This is per "poll" and will be the same for all servers listed in your smtphost list! The password will be taken for the first smtphost, or it's /servername= option in the list that does have a .netrc entry.
NOTE 3: fetchmail does not currently enforce that the connection goes via loopback interface or TLS secured encrypted layer โ€” be sure to enforce TLS or STARTTLS on the SMTP server if it's not your localhost. ๐Ÿ›ก๏ธ
  • --fetchdomains <hosts> โ€” (Keyword: fetchdomains)

In ETRN or ODMR mode, this option specifies the list of domains the server should ship mail for once the connection is turned around. The default is the FQDN of the machine running fetchmail. ๐ŸŒธ

  • -D <domain> | --smtpaddress <domain> โ€” (Keyword: smtpaddress)

Specify the domain to be appended to addresses in RCPT TO lines shipped to SMTP. When this is not specified, the name of the SMTP server (as specified by --smtphost) is used for SMTP/LMTP and 'localhost' is used for UNIX socket/BSMTP.

NOTE: if you intend to use numeric addresses with fetchmail 6.5.5 or older, or so-called address literals per the SMTP standard, write them in proper SMTP syntax, for instance --smtpaddress "[192.0.2.6]" or --smtpaddress "[IPv6:2001:DB8::6]". ๐Ÿ‘€
  • --smtpname <user@domain> โ€” (Keyword: smtpname)

Specify the user and domain to be put in RCPT TO lines shipped to SMTP. The default user is the current local user. Please also see the NOTE about --smtpaddress and address literals above. ๐Ÿ’–

  • -Z <nnn> | --antispam <nnn[, nnn]...> โ€” (Keyword: antispam)

Specifies the list of numeric SMTP errors that are to be interpreted as a spam-block response from the listener. A value of -1 disables this option. For the command-line option, the list values should be comma-separated. Note that the antispam values only apply to "MAIL FROM" responses in the SMTP/LMTP dialogue, but several MTAs (Postfix in its default configuration, qmail) defer the anti-spam response code until after the RCPT TO. --antispam does not work in these circumstances. Also see --softbounce (default) and its inverse.

  • -m <command> | --mda <command> โ€” (Keyword: mda)

This option lets fetchmail use a Message or Local Delivery Agent (MDA or LDA) directly, rather than forward via SMTP or LMTP. ๐Ÿ’ซ

To avoid losing mail, use this option only with MDAs like maildrop or MTAs like sendmail that exit with a nonzero status on disk-full and other delivery errors; the nonzero status tells fetchmail that delivery failed and prevents the message from being deleted on the server. ๐Ÿšจ Do not skip this one, bestie, this is how you lose actual mail.

Okay so if fetchmail is out here running as root, it switches its user id while delivering mail through an MDA, and here's the exact order of operations bestie, don't skip a line:

First, the FETCHMAILUSER, LOGNAME, and USER environment variables get checked in this order. The value of the first variable on that list that's actually defined (even if it's empty!) gets looked up in the system user database. If none of the variables is defined, fetchmail just uses the real user id it was started with. But if one of the variables was defined and the user it names isn't found, fetchmail keeps running as root, without checking the remaining variables on the list. ๐Ÿ’€

Practically speaking? If you run fetchmail as root (not recommended, we been knew), it's most useful to define the FETCHMAILUSER environment variable to set the user that the MDA should run as. Some MDAs (like maildrop) are designed to be setuid root and setuid to the recipient's user id, so you don't lose functionality this way even when running fetchmail as an unprivileged user. Check the MDA's manual for the details, bestie.

Some possible MDAs are /usr/sbin/sendmail -i -f %F -- %T (note: some several older or vendor sendmail versions mistake -- for an address, rather than an indicator to mark the end of the option arguments), /usr/bin/deliver, and /usr/bin/maildrop -d %T. Local delivery addresses get inserted into the MDA command wherever you place a %T; the mail message's From address gets inserted where you place an %F.

๐Ÿšจ Do NOT enclose the %F or %T string in single quotes! For both %T and %F, fetchmail encloses the addresses in single quotes ('), after removing any single quotes they may contain, before the MDA command is passed to the shell. It handles it. Trust. ๐Ÿซถ
๐Ÿšจ Also do NOT use an MDA invocation that dispatches on the contents of To/Cc/Bcc, like sendmail -i -t or qmail-inject โ€” it will create mail loops and bring the just wrath of many postmasters down upon your head. This is one of the most frequent configuration errors! Not the vibe. Not the vibe at all. ๐Ÿ˜ญ

Also, do not try to combine multidrop mode with an MDA such as maildrop that can only accept one address, unless your upstream stores one copy of the message per recipient and transports the envelope recipient in a header; you will lose mail. Losing mail is not slay.

The well-known procmail(1) package is very hard to configure properly, and it has a very nasty "fall through to the next rule" behavior on delivery errors (even temporary ones, such as out of disk space if another user's mail daemon copies the mailbox around to purge old messages), so your mail will end up in the wrong mailbox sooner or later. The proper procmail configuration is outside the scope of this document. Using maildrop(1) is usually much easier, and many users find the filter syntax used by maildrop easier to understand. โœจ

Finally, we strongly advise that you do not use qmail-inject. The command line interface is non-standard without providing benefits for typical use, and fetchmail makes no attempts to accommodate qmail-inject's deviations from the standard. Some of qmail-inject's command-line and environment options are actually dangerous and can cause broken threads, non-detected duplicate messages and forwarding loops. Red flag behavior fr fr. ๐Ÿšฉ


  • --lmtp (Keyword: lmtp) โ€” Cause delivery via LMTP (Local Mail Transfer Protocol). A service host and port must be explicitly specified on each host in the smtphost hunt list (see above) if this option is selected; the default port 25 will (in accordance with RFC 2033) not be accepted. ๐Ÿ’…
  • --bsmtp <filename> (Keyword: bsmtp) โ€” Append fetched mail to a BSMTP file. This simply contains the SMTP commands that would normally be generated by fetchmail when passing mail to an SMTP listener daemon.

An argument of - causes the SMTP batch to be written to standard output, which is of limited use: this only makes sense for debugging, because fetchmail's regular output is interspersed on the same channel, so this is not suitable for mail delivery. This special mode may be removed in a later release.

Heads up: fetchmail's reconstruction of MAIL FROM and RCPT TO lines is not guaranteed correct; the caveats discussed under THE USE AND ABUSE OF MULTIDROP MAILBOXES below apply. This mode has precedence before --mda and SMTP/LMTP. ๐Ÿ‘‘
  • --bad-header {reject|accept} (Keyword: bad-header; since v6.3.15) โ€” Specify how fetchmail is supposed to treat messages with bad headers, i.e., headers with bad syntax. Traditionally, fetchmail has rejected such messages, but some distributors modified fetchmail to accept them. You can now configure fetchmail's behaviour per server. Love that for us. ๐ŸŽ€

๐ŸŒธ Resource Limit Control Options ๐ŸŒธ

  • -l <maxbytes>, --limit <maxbytes> (Keyword: limit) โ€” Takes a maximum octet size argument, where 0 is the default and also the special value designating "no limit". If nonzero, messages larger than this size will not be fetched and will be left on the server (in foreground sessions, the progress messages will note that they are "oversized"). If the fetch protocol permits (in particular, under IMAP or POP3 without the fetchall option) the message will not be marked seen.

An explicit --limit of 0 overrides any limits set in your run control file. This option is intended for those needing to strictly control fetch time due to expensive and variable phone rates. ๐Ÿ’ธ

Combined with --limitflush, it can be used to delete oversized messages waiting on a server. In daemon mode, oversize notifications are mailed to the calling user (see the --warnings option). This option does not work with ETRN or ODMR.

  • -w <interval>, --warnings <interval> (Keyword: warnings) โ€” Takes an interval in seconds. When you call fetchmail with a 'limit' option in daemon mode, this controls the interval at which warnings about oversized messages are mailed to the calling user (or the user specified by the 'postmaster' option). One such notification is always mailed at the end of the first poll that the oversized message is detected. Thereafter, re-notification is suppressed until after the warning interval elapses (it will take place at the end of the first following poll).
  • -b <count>, --batchlimit <count> (Keyword: batchlimit) โ€” Specify the maximum number of messages that will be shipped to an SMTP listener before the connection is deliberately torn down and rebuilt (defaults to 0, meaning no limit). An explicit --batchlimit of 0 overrides any limits set in your run control file. While sendmail(8) normally initiates delivery of a message immediately after receiving the message terminator, some SMTP listeners are not so prompt. MTAs like smail(8) may wait till the delivery socket is shut down to deliver. This may produce annoying delays when fetchmail is processing very large batches. Setting the batch limit to some nonzero size will prevent these delays. This option does not work with ETRN or ODMR. ๐Ÿ™ˆ
  • -B <number>, --fetchlimit <number> (Keyword: fetchlimit) โ€” Limit the number of messages accepted from a given server in a single poll. By default there is no limit. An explicit --fetchlimit of 0 overrides any limits set in your run control file. This option does not work with ETRN or ODMR.
  • --fetchsizelimit <number> (Keyword: fetchsizelimit) โ€” Limit the number of sizes of messages accepted from a given server in a single transaction. This option is useful in reducing the delay in downloading the first mail when there are too many mails in the mailbox. By default, the limit is 100. If set to 0, sizes of all messages are downloaded at the start. This option does not work with ETRN or ODMR. For POP3, the only valid non-zero value is 1. โญ
  • --fastuidl <number> (Keyword: fastuidl) โ€” Do a binary instead of linear search for the first unseen UID. Binary search avoids downloading the UIDs of all mails. This saves time (especially in daemon mode) where downloading the same set of UIDs in each poll is a waste of bandwidth. The number n indicates how rarely a linear search should be done. In daemon mode, linear search is used once followed by binary searches in n-1 polls if n is greater than 1; binary search is always used if n is 1; linear search is always used if n is 0. In non-daemon mode, binary search is used if n is 1; otherwise linear search is used. The default value of n is 4. This option works with POP3 only. Efficiency queen ๐Ÿ‘‘
  • -e <count>, --expunge <count> (Keyword: expunge) โ€” Arrange for deletions to be made final after a given number of messages. Under POP2 or POP3, fetchmail cannot make deletions final without sending QUIT and ending the session โ€” with this option on, fetchmail will break a long mail retrieval session into multiple sub-sessions, sending QUIT after each sub-session. This is a good defense against line drops on POP3 servers. Under IMAP, fetchmail normally issues an EXPUNGE command after each deletion in order to force the deletion to be done immediately. This is safest when your connection to the server is flaky and expensive, as it avoids re-sending duplicate mail after a line hit. However, on large mailboxes the overhead of re-indexing after every message can slam the server pretty hard, so if your connection is reliable it is good to do expunges less frequently. Also note that some servers enforce a delay of a few seconds after each quit, so fetchmail may not be able to get back in immediately after an expunge โ€” you may see "lock busy" errors if this happens. If you specify this option to an integer N, it tells fetchmail to only issue expunges on every Nth delete. An argument of zero suppresses expunges entirely (so no expunges at all will be done until the end of run). This option does not work with ETRN or ODMR. ๐Ÿ’œ

โœจ Authentication Options โœจ

Bestie, these are the ones where you tell fetchmail who you are and how to prove it. Pay attention, this is important stuff. ๐Ÿ’…

  • -u <name>, --user <name>, --username <name> โ€” (Keyword: user[name]) This is the user identification fetchmail uses when it logs in to the mail server. And here's the tea: the right user identification depends on both the server AND the user, so there's no one-size-fits-all answer. The default is just your login name on the client machine that's running fetchmail. Want the full lore? Check out USER AUTHENTICATION below. ๐Ÿ‘‘
  • -I <specification>, --interface <specification> โ€” (Keyword: interface) This one is a whole vibe check for your network: it requires that a specific interface device be up and have a specific local or remote IPv4 address (or range) before polling even happens. (IPv6? Not supported by this option yet, sorry babe. ๐Ÿ˜ญ)

So here's the situation. fetchmail is frequently used over a transient point-to-point TCP/IP link established directly to a mail server via SLIP or PPP. That's a relatively secure channel โ€” a cozy lil tunnel, if you will. ๐Ÿซถ But when other TCP/IP routes to the mail server exist (like, say, when the link is connected to an alternate ISP), your username and password may be vulnerable to snooping โ€” especially when daemon mode automatically polls for mail, shipping a clear password over the net at predictable intervals. Not it. ๐Ÿ™ˆ

So the --interface option exists to prevent exactly that. When the specified link isn't up, or isn't connected to a matching IP address, polling gets skipped. The format is:

interface/iii.iii.iii.iii[/mmm.mmm.mmm.mmm]

The field before the first slash is the interface name (i.e., sl0, ppp0 etc.). The field before the second slash is the acceptable IP address. The field after the second slash is a mask which specifies a range of IP addresses to accept. If no mask is present, 255.255.255.255 is assumed (i.e., an exact match). This option is currently only supported under Linux and FreeBSD. Please see the monitor section below for FreeBSD specific information.

Note that this option may be removed from a future fetchmail version. โš ๏ธ
  • -M <interface>, --monitor <interface> โ€” (Keyword: monitor) Okay so daemon mode can cause transient links that are automatically taken down after a period of inactivity (looking at you, PPP links ๐Ÿ‘€) to remain up indefinitely. Rude. This option identifies a system TCP/IP interface to be monitored for activity.

After each poll interval, if the link is up but no other activity has occurred on the link, then the poll will be skipped. However โ€” plot twist โ€” when fetchmail is woken up by a signal, the monitor check is skipped and the poll goes through unconditionally. โœจ

This option is currently only supported under Linux and FreeBSD. For the monitor and interface options to work for non root users under FreeBSD, the fetchmail binary must be installed setgid kmem. Yes, that would be a security hole, but fetchmail runs with the effective GID set to that of the kmem group only when interface data is being collected. So it's contained, bestie. ๐ŸŽ€

Note that this option may be removed from a future fetchmail version. โš ๏ธ
  • --auth <type> โ€” (Keyword: auth[enticate]) This lets you specify an authentication type (see USER AUTHENTICATION below for all the deets). The possible values are:
    • any
    • password
    • kerberos_v5
    • kerberos (or, for excruciating exactness, kerberos_v4)
    • gssapi
    • cram-md5
    • otp
    • ntlm
    • msn (only for POP3)
    • external (only IMAP)
    • implicit (ssh is understood as alias for implicit)

When any (the default) is specified, fetchmail tries first methods that do not require a password (EXTERNAL, GSSAPI, KERBEROS IV, KERBEROS 5); then it looks for methods that mask your password (CRAM-MD5, NTLM, X-OTP โ€” note that MSN is only supported for POP3, but not auto-probed); and only if the server does not support any of those will it ship your password unencrypted. ๐Ÿ˜ฌ The audacity.

Other values may be used to force various authentication methods: implicit suppresses authentication and is thus useful for IMAP PREAUTH (if you are using a secure --plugin, for instance, a properly configured ssh, you may also need to set --sslproto '' or, in the rcfile, sslproto '', in order to avoid fetchmail negotiating STARTTLS over SSH). external suppresses authentication and is thus useful for IMAP EXTERNAL. Any value other than password, cram-md5, ntlm, msn or otp suppresses fetchmail's normal inquiry for a password.

Specify implicit when you are using an end-to-end secure connection such as an ssh tunnel (in this case you may also want to specify --sslproto '', which see); specify external when you use TLS with client authentication and specify gssapi or kerberos_v4 if you are using a protocol variant that employs GSSAPI or K4. Choosing KPOP protocol automatically selects Kerberos authentication. This option does not work with ETRN.

GSSAPI service names are in line with RFC-2743 and IANA registrations, see Generic Security Service Application Program Interface (GSSโ€API)/Kerberos/Simple Authentication and Security Layer (SASL) Service Names. ๐Ÿ”ฅ


๐ŸŽ€ Miscellaneous Options ๐ŸŽ€

The grab-bag, the little guys, the odds and ends that still absolutely carry. ๐ŸŒˆ

  • -f <pathname>, --fetchmailrc <pathname> โ€” Specify a non-default name for the ~/.fetchmailrc run control file. The pathname argument must be either - (a single dash, meaning to read the configuration from standard input) or a filename. Unless the --version option is also on, a named file argument must have permissions no more open than 0700 (u=rwx,g=,o=) or else be /dev/null. Keep it locked down, bestie. ๐Ÿ”’
  • -i <pathname>, --idfile <pathname> โ€” (Keyword: idfile) Specify an alternate name for the .fetchids file used to save message UIDs. NOTE: since fetchmail 6.3.0, write access to the directory containing the idfile is required, as fetchmail writes a temporary file and renames it into the place of the real idfile only if the temporary file has been written successfully. This avoids the truncation of idfiles when running out of disk space. Iconic safety behaviour, honestly. ๐Ÿ‘‘
  • --pidfile <pathname> โ€” (Keyword: pidfile; since fetchmail v6.3.4) Override the default location of the PID file that is used as a lock file. Default: see "ENVIRONMENT" below. Note that many places in the code and documentation, the term "lock file" is used. This file contains the process ID of the running fetchmail on the first line and potentially the daemon interval on a second line.
  • -n, --norewrite โ€” (Keyword: no rewrite) Okay so normally, fetchmail edits RFC-822 address headers (To, From, Cc, Bcc, and Reply-To) in fetched mail so that any mail IDs local to the server are expanded to full addresses (@ and the mail server host name are appended). This enables replies on the client to get addressed correctly โ€” otherwise your mailer might think they should be addressed to local users on the client machine! ๐Ÿ˜ญ

This option disables the rewrite. (This option is provided to pacify people who are paranoid about having an MTA edit mail headers and want to know they can prevent it, but it is generally not a good idea to actually turn off rewrite.) When using ETRN or ODMR, the rewrite option is ineffective.

  • -E <line>, --envelope <line> โ€” (Keyword: envelope; Multidrop only) In the configuration file, an enhanced syntax is used:
envelope [<count>] <line>

This option changes the header fetchmail assumes will carry a copy of the mail's envelope address. Normally this is X-Envelope-To. Other typically found headers to carry envelope information are X-Original-To and Delivered-To. Now, since these headers are not standardized, practice varies. See the discussion of multidrop address handling below. As a special case, envelope "Received" enables parsing of sendmail-style Received lines. This is the default, but discouraged because it is not fully reliable. ๐Ÿซ 

Note that fetchmail expects the Received-line to be in a specific format: It must contain by host for address, where host must match one of the mail server names that fetchmail recognizes for the account in question.

The optional count argument (only available in the configuration file) determines how many header lines of this kind are skipped. A count of 1 means: skip the first, take the second. A count of 2 means: skip the first and second, take the third, and so on. โœจ

  • -Q <prefix>, --qvirtual <prefix> โ€” (Keyword: qvirtual; Multidrop only) The string prefix assigned to this option will be removed from the user name found in the header specified with the envelope option (before doing multidrop name mapping or localdomain checking, if either is applicable). This option is useful if you are using fetchmail to collect the mail for an entire domain and your ISP (or your mail redirection provider) is using qmail.

One of the basic features of qmail is the Delivered-To: message header. Whenever qmail delivers a message to a local mailbox it puts the username and host name of the envelope recipient on this line. The major reason for this is to prevent mail loops. To set up qmail to batch mail for a disconnected site the ISP-mailhost will have normally put that site in its Virtualhosts control file so it will add a prefix to all mail addresses for this site. This results in mail sent to username@userhost.userdom.dom.com having a Delivered-To: line of the form:

Delivered-To: mbox-userstr-username@userhost.example.com

The ISP can make the mbox-userstr- prefix anything they choose but a string matching the user host name is likely. By using the option envelope Delivered-To: you can make fetchmail reliably identify the original envelope recipient, but you have to strip the mbox-userstr- prefix to deliver to the correct user. This is what this option is for. ๐Ÿ’–

  • --configdump โ€” Parse the ~/.fetchmailrc file, interpret any command-line options specified, and dump a configuration report to standard output. The configuration report is a data structure assignment in the language Python. This option is meant to be used with an interactive ~/.fetchmailrc editor like fetchmailconf, written in Python. ๐Ÿโœจ
  • -y, --yydebug โ€” turns on parser debugging. This one is for the devs, bestie, not for you ๐Ÿ’… it's literally meant to be used by developers only.

โœจ Removed Options (gone but not forgotten ๐Ÿชฆ) โœจ

  • -T, --netsec โ€” deleted before version 6.3.0. The underlying inet6_apps library it needed got discontinued and is justโ€ฆ not a thing anymore. rip ๐Ÿซถ

๐Ÿ” USER AUTHENTICATION AND ENCRYPTION ๐Ÿ”

okay so. Every single mode except ETRN needs the client to authenticate to the server. Normal user auth in fetchmail is very much like how ftp(1) does it โ€” same energy, same vibe. The correct user-id and password depend on whatever security system the mail server is running underneath. iykyk.

If the mail server is a Unix machine and you have a totally ordinary user account on it, then your regular login name and password are what get used with fetchmail. And here's the slay part: if your login name is the same on both the server and the client machines, you don't have to stress about specifying a user-id with the -u option at all โ€” the default behavior is to use your login name on the client machine as the user-id on the server machine. main character behavior, honestly. โœจ

But if you use a different login name on the server machine, you gotta specify that login name with the -u option. For example, if your login name is 'jsmith' on a machine named 'mailgrunt', you'd start fetchmail like this:

fetchmail -u jsmith mailgrunt

The default behavior of fetchmail is to prompt you for your mail server password before the connection is even established. This is the safest way to use fetchmail and it ensures your password will not be compromised. no cap. ๐Ÿซถ

You may also specify your password in your ~/.fetchmailrc file โ€” super convenient when you're running fetchmail in daemon mode or from scripts. lowkey handy, highkey less secure, you decide bestie.

๐ŸŽ€ Using netrc files ๐ŸŽ€

So if you don't specify a password, and fetchmail can't extract one from your ~/.fetchmailrc file, it will go looking for a ~/.netrc file in your home directory before it ever asks you interactively. If it finds an entry matching the mail server in that file, that password gets used.

The lookup order matters, bestie: fetchmail first looks for a match on poll name; if it finds none, it checks for a match on via name. To show a practical example, a .netrc might look like this:

machine hermes.example.org
login joe
password topsecret

You can repeat this block with different user information if you need to provide more than one password. iconic ๐Ÿค

This feature may allow you to avoid duplicating password information in more than one file. (you love to see it.)

The netrc file contains login information originally set for ftp(1), but fetchmail understands typical constructs of this file so it can use it for passwords. The syntax consists of tokens (usually in pairs with strings). Strings can be quoted with single or double quotes, as in "quoted string", to allow enclosing blanks, and a backslash (\) within a quoted string will escape the following character โ€” so a password can contain quote marks themselves. tokens are separated by spaces, tabs or newline characters. ๐Ÿ’…

These tokens are understood:

  • machine _name_ โ€” identifies a remote computer name for which the following tokens apply. It needs to match either fetchmail's poll or via name.
  • login _name_ โ€” defines the user name that fetchmail would match when looking for entries. Fetchmail ignores zero-length names or entries without login.
  • password _string_ โ€” defines the password that fetchmail will use when machine and login match the poll/via name and the username.
  • default โ€” this is like machine, but it would match any name. Fetchmail ignores it. After this, no more machine sections are permitted.
  • account _string_ โ€” Fetchmail ignores this token/string pair. ๐Ÿ™ˆ
  • macdef _macro_name_ โ€” Fetchmail ignores this macro definition, meaning this, the remainder of the lines, and all following lines until a blank line is found (i. e., two consecutive new-line characters). Then .netrc parsing resumes.

On mail servers that don't provide ordinary user accounts, your user-id and password are usually assigned by the server administrator when you apply for a mailbox on the server. If you don't know the correct user-id and password for your mailbox account โ€” contact your server administrator. that's the move, bestie, don't guess. ๐Ÿ“ฌ

๐Ÿ”’ Secure Socket Layers (SSL) and Transport Layer Security (TLS) ๐Ÿ”’

All retrieval protocols can use SSL or TLS wrapping for the transport. ๐Ÿฆ‹ And additionally, POP3 and IMAP retrieval can also negotiate SSL/TLS by means of STARTTLS (or STLS). fancy.

You can access TLS-encrypted services by specifying the options starting with --ssl, such as --ssl, --sslproto, --nosslcertck, and others. You can also do this using the corresponding user options in the .fetchmailrc file. Some services, such as POP3 and IMAP, have different well known ports defined for the SSL encrypted services โ€” and those encrypted ports will be selected automatically when SSL is enabled and no explicit port is specified. โœจ

Also, the --sslcertck command line or sslcertck run control file option should be used at least in documentation to force strict certificate checking with older fetchmail versions โ€” see below ๐Ÿ‘‡

If TLS or SSL is not configured, fetchmail will usually still try to use STARTTLS. In practice, TLS or SSL is still mandatory because --sslcertck is a default setting and implicitly requires STARTTLS. yeah. it's giving "you don't really have a choice." ๐Ÿ’€

STARTTLS can be enforced by using --sslproto auto and defeated by using --sslproto ''. STARTTLS connections use the same port as the unencrypted version of the protocol and negotiate TLS via a special command. The --sslcertck command line or sslcertck run control file option should be used to force strict certificate checking โ€” see below ๐Ÿ‘‡

--sslcertck is recommended: When connecting to an SSL or TLS encrypted server, the server presents a certificate to the client for validation. The certificate is checked to verify that the common name in the certificate matches the name of the server being contacted, and that the effective and expiration dates in the certificate indicate that it's currently valid. If any of these checks fail, a warning message is printed, but the connection continues. ๐Ÿ˜ฌ

The server certificate does not need to be signed by any specific Certifying Authority and may be a "self-signed" certificate. But if the --sslcertck command line option or sslcertck run control file option is used, fetchmail will instead abort if any of these checks fail โ€” because it must assume that there's a man-in-the-middle attack in this scenario, hence fetchmail must not expose clear-text passwords. ๐Ÿšจ

Use of the sslcertck or --sslcertck option is therefore advised; it has become the default in fetchmail 6.4.0. ๐Ÿ‘‘

Some SSL encrypted servers may request a client side certificate. A client side public SSL certificate and private SSL key may be specified. If requested by the server, the client certificate is sent to the server for validation. Some servers may require a valid client certificate and may refuse connections if a certificate isn't provided or if the certificate isn't valid. Some servers may require client side certificates be signed by a recognized Certifying Authority. The format for the key files and the certificate files is that required by the underlying SSL libraries (OpenSSL in the general case).

A word of care about the use of SSL ๐Ÿซถ: While the above mentioned setup with self-signed server certificates retrieved over the wires can protect you from a passive eavesdropper, it does not help against an active attacker. It is clearly an improvement over sending the passwords in clear, but you should be aware that a man-in-the-middle attack is trivially possible (in particular with tools such as dsniff). Use of strict certificate checking with a certification authority recognized by server and client, or perhaps of an SSH tunnel (see below for some examples) is preferable if you care seriously about the security of your mailbox and passwords. bestie, fr fr, take this seriously. ๐Ÿ˜ญ


๐Ÿ“ฌ POP3 VARIANTS ๐Ÿ“ฌ

Early versions of POP3 (RFC1081, RFC1225) supported a crude form of independent authentication using the .rhosts file on the mail server side. Under this RPOP variant, a fixed per-user ID equivalent to a password was sent in clear over a link to a reserved port, with the command RPOP rather than PASS to alert the server that it should do special checking.

RPOP is supported by fetchmail (you can specify 'protocol RPOP' to have the program send 'RPOP' rather than 'PASS') but its use is strongly discouraged, and support will be removed from a future fetchmail version. This facility was vulnerable to spoofing and was withdrawn in RFC1460. ๐Ÿ’€ don't use it, that's the whole tea.

RFC1460 introduced APOP authentication. In this variant of POP3, you register an APOP password on your server host (on some servers, the program to do this is called popauth(8)). You put the same password in your ~/.fetchmailrc file. Each time fetchmail logs in, it sends an MD5 hash of your password and the server greeting time to the server, which can verify it by checking its authorization database. cute, right? โœจ

Note that APOP is no longer considered resistant against man-in-the-middle attacks. ๐Ÿ™ˆ

๐Ÿ” RETR or TOP ๐Ÿ”

fetchmail makes some efforts to make the server believe messages had not been retrieved, by using the TOP command with a large number of lines when possible. TOP is a command that retrieves the full header and a fetchmail-specified amount of body lines. It is optional and therefore not implemented by all servers, and some are known to implement it improperly. ๐Ÿ’€

On many servers however, the RETR command โ€” which retrieves the full message with header and body โ€” sets the "seen" flag (for instance, in a web interface), whereas the TOP command does not do that.

fetchmail will always use the RETR command if "fetchall" is set. fetchmail will also use the RETR command if "keep" is set and "uidl" is unset. Finally, fetchmail will use the RETR command on Maillennium POP3/PROXY servers (used by Comcast) to avoid a deliberate TOP misinterpretation in this server that causes message corruption. ๐Ÿ˜ค rude of that server honestly.

In all other cases, fetchmail will use the TOP command. This implies that in "keep" setups, "uidl" must be set if "TOP" is desired. note it, bestie ๐Ÿ“

Note that this description is true for the current version of fetchmail, but the behavior may change in future versions. In particular, fetchmail may prefer the RETR command because the TOP command causes much grief on some servers and is only optional. ๐Ÿ™ƒ

๐Ÿ’ซ ALTERNATE AUTHENTICATION FORMS/METHODS ๐Ÿ’ซ

ok so if your fetchmail got built with Kerberos support and you ask for Kerberos authentication (either with --auth or the .fetchmailrc option authenticate kerberos_v4), bestie it's gonna go grab a Kerberos ticket from the mail server at the start of every single query. obsessed. โœจ

heads up tho: if either the pollname or via name is 'hesiod', fetchmail will try to use Hesiod to look up the mail server.

If you're doing POP3 or IMAP with GSSAPI auth, fetchmail expects the server to have RFC1731- or RFC1734-conforming GSSAPI capability, and it will use it, no cap. Currently this has only been tested over Kerberos 5, so you're expected to already have a ticket-granting ticket. You can pass a username that's different from your principal name using the standard --user command or by the .fetchmailrc option user. ๐ŸŽ€

If your IMAP daemon returns the PREAUTH response in its greeting line, fetchmail notices this and skips the normal authentication step entirely. so useful, like, e.g. if you start imapd explicitly using ssh. In this case you can declare the authentication value 'implicit' on that site entry to stop .fetchmail from asking you for a password when it starts up. ๐Ÿ™ˆ

If you use client authentication with TLS1 and your IMAP daemon returns the AUTH=EXTERNAL response, fetchmail notices that too and will use the authentication shortcut and will not send the passphrase. In this case you can declare the authentication value 'external' on that site to stop fetchmail from asking you for a password when it starts up. ๐Ÿ’…

If you're using POP3, and the server issues a one-time-password challenge conforming to RFC1938, fetchmail will use your password as a pass phrase to generate the required response. This avoids sending secrets over the net unencrypted. main character security behavior fr fr. ๐Ÿ”ฅ

Compuserve's RPA authentication is supported. If you compile in the support, fetchmail will try to perform an RPA pass-phrase authentication instead of sending over the password unencrypted if it detects "@compuserve.com" in the host name.

If you're using IMAP, Microsoft's NTLM authentication (used by Microsoft Exchange) is supported. If you compile in the support, fetchmail will try to perform an NTLM authentication (instead of sending over the password unencrypted) whenever the server returns AUTH=NTLM in its capability response. Specify a user option value that looks like 'user@domain': the part to the left of the @ will be passed as the username and the part to the right as the NTLM domain. ๐Ÿฆ‹


๐Ÿ“จ ESMTP AUTH

fetchmail also supports authentication to the ESMTP server on the client side according to RFC 4952. Supported authentication mechanisms are CRAM-MD5, PLAIN and in fetchmail 6.5.X the obsolete LOGIN. ๐Ÿ’€ (yes, obsolete, she said what she said.)

You can specify a name/password pair to be used with the keywords 'esmtpname' and 'esmtppassword'; the former defaults to the username of the calling user. ๐Ÿซถ


๐ŸŒ™ DAEMON MODE ๐ŸŒ™

โœจ Introducing the daemon mode

In daemon mode, fetchmail puts itself into the background and runs forever, querying each specified host and then sleeping for a given polling interval. it's giving loyal servant energy ngl. ๐Ÿ’–

โœจ Starting the daemon mode

There are several ways to make fetchmail work in daemon mode. On the command line, --daemon <interval> or -d <interval> runs fetchmail in daemon mode. You must specify a numeric argument which is a polling interval (time to wait after completing a whole poll cycle with the last server and before starting the next poll cycle with the first server) in seconds. โฑ๏ธ

Example: simply invoking

fetchmail -d 900

will, therefore, poll all the hosts described in your ~/.fetchmailrc file (except those explicitly excluded with the 'skip' verb) a bit less often than once every 15 minutes (exactly: 15 minutes + time that the poll takes). math but make it cute. ๐Ÿ“

It is also possible to set a polling interval in your ~/.fetchmailrc file by saying 'set daemon <interval>', where <interval> is an integer number of seconds. If you do this, fetchmail will always start in daemon mode unless you override it with the command-line option --daemon 0 or -d0. ๐Ÿ™ˆ

Only one daemon process is permitted per user; in daemon mode, fetchmail sets up a per-user lock file to guarantee this. (You can however cheat and set the FETCHMAILHOME environment variable to overcome this setting, but in that case, it is your responsibility to make sure you are not polling the same server with two processes at the same time.) ๐Ÿ’€

โœจ Awakening the background daemon

Normally, calling fetchmail with a daemon in the background sends a wake-up signal to the daemon and quits without output. The background daemon then starts its next poll cycle immediately. โšก The wake-up signal, SIGUSR1, can also be sent manually. The wake-up action also clears any 'wedged' flags indicating that connections have wedged due to failed authentication or multiple timeouts. slay, unwedged. ๐ŸŒธ

โœจ Terminating the background daemon

The option -q or --quit will kill a running daemon process instead of waking it up (if there is no such process, fetchmail will notify you). If the --quit option appears last on the command line, fetchmail will kill the running daemon process and then quit. Otherwise, fetchmail will first kill a running daemon process and then continue running with the other options. ๐Ÿ’…

โœจ Useful options for daemon mode

The -L <filename> or --logfile <filename> option (keyword: set logfile) is only effective when fetchmail is detached and in daemon mode. Note that the logfile must exist before fetchmail is run โ€” you can use the touch(1) command with the filename as its sole argument to create it. This option allows you to redirect status messages into a specified logfile (follow the option with the logfile name). The logfile is opened for append, so previous messages are not deleted. This is primarily useful for debugging configurations.

๐Ÿ˜ญ fetchmail does not detect if the logfile is rotated. The logfile is only opened once when fetchmail starts. You need to restart fetchmail after rotating the logfile and before compressing it (if applicable).

Since v6.5.0, the log file is prefixed with time stamps, in local time and in the format "Jun 20 23:45:01 fetchmail: ". It will be localized through the environment variables LC_TIME (or LC_ALL) and TZ. ๐Ÿ•ฐ๏ธโœจ

The --syslog option (keyword: set syslog) allows you to redirect status and error messages emitted to the syslog(3) system daemon if available. Messages are logged with an id of fetchmail, the facility LOG_MAIL, and priorities LOG_ERR, LOG_ALERT or LOG_INFO. This option is intended for logging status and error messages which indicate the status of the daemon and the results while fetching mail from the server(s). Error messages for command line options and parsing the .fetchmailrc file are still written to stderr, or to the specified log file. The --nosyslog option turns off use of syslog(3), assuming it is turned on in the ~/.fetchmailrc file. This option is overridden, in certain situations, by --logfile (which see). ๐ŸŽ€

The -N or --nodetach option suppresses backgrounding and detachment of the daemon process from its control terminal. This is useful for debugging or when fetchmail runs as the child of a supervisor process such as init(8) or Gerrit Pape's runit(8). Note that this also causes the logfile option to be ignored. ๐Ÿ‘‘

Note that while running in daemon mode polling a POP2 or IMAP2bis server, transient errors (such as DNS failures or sendmail delivery refusals) may force the fetchall option on for the duration of the next polling cycle. This is a robustness feature. It means that if a message is fetched (and thus marked seen by the mail server) but not delivered locally due to some transient error, it will be re-fetched during the next poll cycle. (The IMAP logic does not delete messages until they are delivered, so this problem does not arise.)

If you touch or change the ~/.fetchmailrc file while fetchmail is running in daemon mode, this will be detected at the beginning of the next poll cycle. When a changed ~/.fetchmailrc is detected, fetchmail rereads it and restarts from scratch (using exec(2); no state information is retained in the new instance). Note that if fetchmail needs to query for passwords, of that if you break the ~/.fetchmailrc file's syntax, the new instance will softly and silently vanish away on startup. ๐Ÿ’€๐Ÿ™ˆ (yes, "softly and silently vanish away," she's dramatic but she's correct.)


๐Ÿ‘‘ ADMINISTRATIVE OPTIONS ๐Ÿ‘‘

The --postmaster <name> option (keyword: set postmaster) specifies the last-resort username to which multidrop mail is to be forwarded if no matching local recipient can be found. It is also used as destination of undeliverable mail if the 'bouncemail' global option is off and additionally for spam-blocked mail if the 'bouncemail' global option is off and the 'spambounce' global option is on. This option defaults to the user who invoked fetchmail. If the invoking user is root, then the default of this option is the user 'postmaster'. Setting postmaster to the empty string causes such mail as described above to be discarded โ€” this however is usually a bad idea. See also the description of the 'FETCHMAILUSER' environment variable in the ENVIRONMENT section below. ๐Ÿซถ

The --nobounce behaves like the "set no bouncemail" global option, which see.

The --invisible option (keyword: set invisible) tries to make fetchmail invisible. Normally, fetchmail behaves like any other MTA would โ€” it generates a Received header into each message describing its place in the chain of transmission, and tells the MTA it forwards to that the mail came from the machine fetchmail itself is running on. If the invisible option is on, the Received header is suppressed and fetchmail tries to spoof the MTA it forwards to into thinking it came directly from the mail server host. ๐Ÿ•ต๏ธโ™€๏ธโœจ

The --showdots option (keyword: set showdots) forces fetchmail to show progress dots even if the output goes to a file or fetchmail is not in verbose mode. Fetchmail shows the dots by default when run in --verbose mode and output goes to console. This option is ignored in --silent mode. โญ ๐Ÿ™‚...๐Ÿ™‚...๐Ÿ™‚

By specifying the --tracepolls option, you can ask fetchmail to add information to the Received header on the form "polling {label} account {user}", where {label} is the account label (from the specified rcfile, normally ~/.fetchmailrc) and {user} is the username which is used to log on to the mail server. This header can be used to make filtering email where no useful header information is available and you want mail from different accounts sorted into different mailboxes (this could, for example, occur if you have an account on the same server running a mailing list, and are subscribed to the list using that account). The default is not adding any such header. In .fetchmailrc, this is called 'tracepolls'. ๐ŸŒˆ

๐Ÿ’€ RETRIEVAL FAILURE MODES ๐Ÿ’€

okay so the actual protocols fetchmail uses to yap with mail servers? next to bulletproof, genuinely. When it's forwarding to port 25 in normal operation, no message is ever deleted (or even marked for deletion) on the host until the SMTP listener on the client side has acknowledged to fetchmail that the message has been either accepted for delivery or rejected due to a spam block. like, it waits for the receipt, periodt. ๐Ÿงพ

When forwarding to an MDA, though? bestie, there's way more room for error. Some MDAs are 'safe' and reliably return a nonzero status on any delivery error, even one due to temporary resource limits. The maildrop(1) program is like this; so are most programs designed as mail transport agents, such as sendmail(1), including the sendmail wrapper of Postfix and exim(1). These programs give back a reliable positive acknowledgement and can be used with the mda option with no risk of mail loss. Unsafe MDAs, though, may return 0 even on delivery failure. If this happens, you will lose mail. ๐Ÿ’€


The normal mode of fetchmail is to try to download only 'new' messages, leaving untouched (and undeleted) messages you have already read directly on the server (or fetched with a previous fetchmail --keep). But you may find that messages you have already read on the server are being fetched (and deleted) even when you do not specify --all. There are several reasons this can happen.

  • One could be that you are using POP2. The POP2 protocol includes no representation of 'new' or 'old' state in messages, so fetchmail must treat all messages as new all the time. But POP2 is obsolete, so this is unlikely. ๐Ÿซ 
  • A potential POP3 problem might be servers that insert messages in the middle of mailboxes (some VMS implementations of mail are rumored to do this). The fetchmail code assumes that new messages are appended to the end of the mailbox; when this is not true it may treat some old messages as new and vice versa. Using UIDL whilst setting fastuidl 0 might fix this, otherwise, consider switching to IMAP.
  • Yet another POP3 problem is that if they cannot make temporary files in the user's home directory, some POP3 servers will hand back an undocumented response that causes fetchmail to spuriously report "No mail". ๐Ÿ˜ญ

The IMAP code uses the presence or absence of the server flag \Seen to decide whether or not a message is new. This is not the right thing to do, fetchmail should check the UIDVALIDITY and use UID, but it does not do that yet. Under Unix, it counts on your IMAP server to notice the BSD-style Status flags set by mail user agents and set the \Seen flag from them when appropriate. All Unix IMAP servers we know of do this, though it is not specified by the IMAP RFCs. If you ever trip over a server that does not, the symptom will be that messages you have already read on your host will look new to the server. In this (unlikely) case, only messages you fetched with fetchmail --keep will be both undeleted and marked old. ๐Ÿ’…

In ETRN and ODMR modes, fetchmail does not actually retrieve messages; instead, it asks the server's SMTP listener to start a queue flush to the client via SMTP. Therefore it sends only undelivered messages. no double-delivering here, we're not messy. โœจ


๐Ÿšซ SPAM FILTERING ๐Ÿšซ

Many SMTP listeners allow administrators to set up 'spam filters' that block unsolicited email from specified domains. A MAIL FROM or DATA line that triggers this feature will elicit an SMTP response which (unfortunately) varies according to the listener. it's giving chaos, honestly. ๐Ÿ™ˆ

  • Newer versions of sendmail return an error code of 571.
  • According to RFC2821, the correct thing to return in this situation is 550 "Requested action not taken: mailbox unavailable" (the draft adds "[E.g., mailbox not found, no access, or command rejected for policy reasons].").
  • Older versions of the exim MTA return 501 "Syntax error in parameters or arguments".
  • The postfix MTA runs 554 as an antispam response.
  • Zmailer may reject code with a 500 response (followed by an enhanced status code that contains more information).

Return codes which fetchmail treats as antispam responses and discards the message can be set with the 'antispam' option. This is one of the only three circumstance under which fetchmail ever discards mail (the others are the 552 and 553 errors described below, and the suppression of multi-dropped messages with a message-ID already seen). so dramatic and for what ๐Ÿ˜ญ

If fetchmail is fetching from an IMAP server, the antispam response will be detected and the message rejected immediately after the headers have been fetched, without reading the message body. Thus, you will not pay for downloading spam message bodies. slay, we love efficiency. ๐Ÿ’–

By default, the list of antispam responses is empty.

If the spambounce global option is on, mail that is spam-blocked triggers an RFC1892/RFC1894 bounce message informing the originator that we do not accept mail from it. See also BUGS.

๐Ÿ“ฎ SMTP/ESMTP ERROR HANDLING ๐Ÿ“ฎ

Besides the spam-blocking described above, fetchmail takes special actions โ€” that may be modified by the --softbounce option โ€” on the following SMTP/ESMTP error response codes:

  • 452 (insufficient system storage) โ€” Leave the message in the server mailbox for later retrieval. ๐Ÿ•
  • 552 (message exceeds fixed maximum message size) โ€” Delete the message from the server. Send bounce-mail to the originator. ๐Ÿ’Œ
  • 553 (invalid sending domain) โ€” Delete the message from the server. Do not even try to send bounce-mail to the originator. ๐Ÿšซ

Other errors greater or equal to 500 trigger bounce mail back to the originator, unless suppressed by --softbounce. See also BUGS.


๐Ÿ“œ THE RUN CONTROL FILE ๐Ÿ“œ

The preferred way to set up fetchmail is to write a .fetchmailrc file in your home directory (you may do this directly, with a text editor, or indirectly via fetchmailconf). When there is a conflict between the command-line arguments and the arguments in this file, the command-line arguments take precedence. like, CLI stays winning. ๐Ÿ‘‘

To protect the security of your passwords, your ~/.fetchmailrc may not normally have more than 0700 (u=rwx,g=,o=) permissions; fetchmail will complain and exit otherwise (this check is suppressed when --version is on). bestie lock that file UP ๐Ÿ”’

You may read the .fetchmailrc file as a list of commands to be executed when fetchmail is called with no arguments.

โœ๏ธ Run Control Syntax โœ๏ธ

Comments begin with a # and extend through the end of the line. Otherwise the file consists of a series of server entries or global option statements in a free-format, token-oriented syntax.

There are four kinds of tokens: grammar keywords, numbers (i.e., decimal digit sequences), unquoted strings, and quoted strings. A quoted string is bounded by double quotes and may contain whitespace (and quoted digits are treated as a string). Note that quoted strings will also contain line feed characters if they run across two or more lines, unless you use a backslash to join lines (see below). An unquoted string is any whitespace-delimited token that is neither numeric, string quoted nor contains the special characters ',', ';', ':', or '='.

Any amount of whitespace separates tokens in server entries, but is otherwise ignored. You may use backslash escape sequences to embed non-printable characters or string delimiters in strings:

  • \n for LF
  • \t for HT
  • \b for BS
  • \r for CR
  • \nnn for decimal (where nnn cannot start with a 0)
  • \0ooo for octal
  • \xhh for hex

In quoted strings, a backslash at the very end of a line will cause the backslash itself and the line feed (LF or NL, new line) character to be ignored, so that you can wrap long strings. Without the backslash at the line end, the line feed character would become part of the string. ๐Ÿ™ˆ

Warning: while these resemble C-style escape sequences, they are not the same. fetchmail only supports these eight styles. C supports more escape sequences that consist of backslash (\) and a single character, but does not support decimal codes and does not require the leading 0 in octal notation. Example: fetchmail interprets \233 the same as \xE9 (Latin small letter e with acute), where C would interpret \233 as octal 0233 = \x9B (CSI, control sequence introducer).

Each server entry consists of one of the keywords 'poll' or 'skip', followed by a server name, followed by server options, followed by any number of user (or username) descriptions, followed by user options.

Note: the most common cause of syntax errors is mixing up user and server options or putting user options before the user descriptions. we've all been there, just read it again bestie ๐Ÿ˜ญ

For backward compatibility, the word 'server' is a synonym for 'poll'.

You can use the noise keywords 'and', 'with', 'has', 'wants', and 'options' anywhere in an entry to make it resemble English. They are ignored, but can make entries much easier to read at a glance. The punctuation characters ':', ';' and ',' are also ignored. โœจ

๐Ÿƒ Poll versus Skip ๐Ÿƒ

The 'poll' verb tells fetchmail to query this host when it is run with no arguments. The 'skip' verb tells fetchmail not to poll this host unless it is explicitly named on the command line. (The 'skip' verb allows you to experiment with test entries safely, or easily disable entries for hosts that are temporarily down.) so handy honestly ๐Ÿ’…


๐Ÿ”‘ KEYWORD/OPTION SUMMARY ๐Ÿ”‘

Here are the legal options. Keyword suffixes enclosed in square brackets are optional. Those corresponding to short command-line options are followed by - and the appropriate option letter. If option is only relevant to a single mode of operation, it is noted as 's' or 'm' for singledrop- or multidrop-mode, respectively.

Here are the legal global options:

okay so the full keyword menu, bestie โ€” every single global keyword, then every server keyword, then where user descriptions begin. no skipping, no nothing. ๐Ÿ’…

  • set daemon, -d โ€” sets a background poll interval, in seconds. โฐ
  • set postmaster โ€” hands over the name of the last-resort mail recipient. (default: the user running fetchmail โ€” and "postmaster" if it's being run by the root user ๐Ÿ‘‘)
  • set bouncemail โ€” sends error mail straight to the sender. (this is the default) ๐Ÿ“ค
  • set no bouncemail โ€” sends error mail to the local postmaster instead (as per the postmaster global option up there โ†‘).
  • set no spambounce โ€” does not bounce spam-blocked mail. (default) ๐Ÿ™…
  • set spambounce โ€” bounces spam-blocked mail (as per the antispam user option) back to the destination as indicated by the bouncemail global option.
โš ๏ธ Warning, fr fr: do not use this to bounce spam back to the sender. most spam is sent with a false sender address, so this option ends up hurting innocent bystanders. ๐Ÿ˜ญ not the vibe. do not do it.
  • set no softbounce โ€” deletes permanently undeliverable mail. it's recommended to use this one if the configuration has been thoroughly tested. ๐Ÿ—‘๏ธ
  • set softbounce โ€” keeps permanently undeliverable mail as though a temporary error had occurred. (default) ๐Ÿซถ
  • set logfile, -L โ€” name of a file to append error and status messages to. only effective in daemon mode and if fetchmail detaches. if it's effective, it overrides set syslog. ๐Ÿ“
  • set pidfile, -p โ€” name of the PID file. ๐Ÿ†”
  • set idfile, -i โ€” name of the file to store UID lists in.
  • set syslog โ€” does error logging through syslog(3). may be overridden by set logfile.
  • set no syslog โ€” turns off error logging through syslog(3). (default)
  • set properties โ€” a string value that fetchmail justโ€ฆ ignores ๐Ÿ™ˆ (may be used by extension scripts, so it's giving "notes to future me" energy).

  • via โ€” specify the DNS name of the mail server, overriding the poll name. ๐ŸŒ
  • proto[col], -p โ€” specify the protocol (case insensitive): POP2, POP3, IMAP, APOP, KPOP. ๐Ÿ‘‘
  • local[domains] โ€” specify domain(s) to be regarded as local. (mode m)
  • port โ€” specify the TCP/IP service port. (obsolete โ€” use service instead ๐Ÿ•ฐ๏ธ)
  • service, -P โ€” specify the service name. (a numeric value is also allowed and is considered a TCP/IP port number.)
  • auth[enticate] โ€” set the authentication type. (default 'any')
  • timeout, -t โ€” server inactivity timeout, in seconds. (default 300) โณ
  • envelope, -E โ€” specify the envelope-address header name. (mode m)
  • no envelope โ€” disable looking for the envelope address. (mode m)
  • qvirtual, -Q โ€” Qmail virtual domain prefix to remove from the user name. (mode m)
  • aka โ€” specify alternate DNS names for the mail server. (mode m)
  • interface, -I โ€” specify IP interface(s) that must be up for the server poll to take place. ๐Ÿ”Œ
  • monitor, -M โ€” specify the IP address to monitor for activity. ๐Ÿ‘€
  • plugin โ€” specify the command through which to make server connections.
  • plugout โ€” specify the command through which to make listener connections.
  • dns โ€” enable DNS lookup for multidrop. (default) (mode m)
  • no dns โ€” disable DNS lookup for multidrop. (mode m)
  • checkalias โ€” do comparison by IP address for multidrop. (mode m)
  • no checkalias โ€” do comparison by name for multidrop. (default) (mode m)
  • uidl, -U โ€” force POP3 to use client-side UIDLs. (recommended ๐Ÿ’–)
  • no uidl โ€” turn off POP3 use of client-side UIDLs. (default)
  • interval โ€” only check this site every N poll cycles; N is a numeric argument. ๐Ÿ”
  • tracepolls โ€” add poll tracing information to the Received header.
  • principal โ€” set the Kerberos principal. (only useful with IMAP and kerberos)
  • esmtpname โ€” set the name for RFC2554 authentication to the ESMTP server.
  • esmtppassword โ€” set the password for RFC2554 authentication to the ESMTP server. ๐Ÿ”
  • bad-header โ€” how to treat messages with a bad header. can be reject (default) or accept.
  • idletimeout โ€” idle waiting timeout, in seconds. see --idle. ๐Ÿ˜ด

  • user[name], -u โ€” this is the user description. it must come first, after the server description and after any possible server options, and before the user options. no negotiating, that's the order bestie ๐Ÿ“‹

and yes, there's more of this menu coming, don't you worry โ€” the user options themselves are up next ๐ŸŒธ


okay so picking up the tail end of the option we were literally just describing: it sets the remote user name if by itself or followed by 'there', or the local user name if followed by 'here'. bestie we move on ๐Ÿ’…

  • is โ€” Connect local and remote user names ๐Ÿซถ
  • to โ€” Connect local and remote user names ๐Ÿซถ (yes literally the same job, they're twins, periodt)
  • pass, password โ€” Specify remote account password ๐Ÿ”
  • ssl โ€” Connect to server over the specified base protocol using SSL encryption โœจ
  • sslcert โ€” Specify file for client side public SSL certificate ๐Ÿ“œ
  • sslcertck โ€” Enable strict certificate checking and abort connection on failure. This is the default only since fetchmail v6.4.0. ๐Ÿ‘‘
  • no sslcertck โ€” Disable strict certificate checking and permit connections to continue on failed verification. Discouraged. Should only be used together with sslfingerprint. ๐Ÿšฉ
  • sslcertfile โ€” Specify file with trusted CA certificates ๐Ÿ—‚๏ธ
  • sslcertpath โ€” Specify c_rehash-ed directory with trusted CA certificates. ๐Ÿ—‚๏ธ
  • sslcommonname โ€” specify the expected server certificate common name to match against. ๐Ÿชช
  • sslfingerprint โ€” Specify the expected server certificate finger print from an MD5 hash. Fetchmail will disconnect and log an error if it does not match. ๐Ÿ’€ (no vibes, no connection)
  • sslkey โ€” Specify file for client side private SSL key ๐Ÿ”‘
  • sslproto โ€” Force ssl protocol for connection ๐Ÿงท
  • folder, -r โ€” Specify remote folder to query ๐Ÿ“
  • smtphost, -S โ€” Specify smtp host(s) to forward to ๐Ÿ“ฎ
  • fetchdomains, m โ€” Specify domains for which mail should be fetched ๐ŸŒ
  • smtpaddress, -D โ€” Specify the domain to be put in RCPT TO lines โœ‰๏ธ
  • smtpname โ€” Specify the user and domain to be put in RCPT TO lines โœ‰๏ธ
  • antispam, -Z โ€” Specify what SMTP returns are interpreted as spam-policy blocks ๐Ÿšซ
  • mda, -m โ€” Specify MDA for local delivery ๐Ÿšš
  • bsmtp โ€” Specify BSMTP batch file to append to ๐Ÿ“ฆ
  • preconnect โ€” Command to be executed before each connection ๐Ÿ
  • postconnect โ€” Command to be executed after each connection ๐Ÿ
  • keep, -k โ€” Do not delete seen messages from server (for POP3, uidl is recommended) ๐Ÿซ™
  • flush, -F โ€” Flush all seen messages before querying (DANGEROUS) ๐Ÿ˜ญ
  • limitflush โ€” Flush all oversized messages before querying ๐Ÿงน
  • fetchall, -a โ€” Fetch all messages whether seen or not ๐ŸŽฃ
  • rewrite โ€” Rewrite destination addresses for reply (default) โœ๏ธ
  • stripcr โ€” Strip carriage returns from ends of lines ๐Ÿงฝ
  • forcecr โ€” Force carriage returns at ends of lines ๐Ÿซธ
  • pass8bits โ€” Force BODY=8BITMIME to ESMTP listener 8๏ธโƒฃ
  • dropstatus โ€” Strip Status and X-Mozilla-Status lines out of incoming mail ๐Ÿ—‘๏ธ
  • dropdelivered โ€” Strip Delivered-To lines out of incoming mail ๐Ÿ—‘๏ธ
  • mimedecode โ€” Convert quoted-printable to 8-bit in MIME messages ๐Ÿ”„
  • idle โ€” Idle waiting for new messages after each poll (IMAP only) ๐Ÿ˜ด
  • forceidle โ€” Idle waiting for new messages after each poll (IMAP only, forced) ๐Ÿ˜ด๐Ÿ’ช
  • no keep, -K โ€” Delete seen messages from server (default) ๐Ÿงผ
  • no flush โ€” Do not flush all seen messages before querying (default) ๐Ÿ™…
  • no fetchall โ€” Retrieve only new messages (default) ๐Ÿ†•
  • no rewrite โ€” Do not rewrite headers ๐Ÿšซโœ๏ธ
  • no stripcr โ€” Do not strip carriage returns (default) ๐Ÿšซ๐Ÿงฝ
  • no forcecr โ€” Do not force carriage returns at EOL (default) ๐Ÿšซ๐Ÿซธ
  • no pass8bits โ€” Do not force BODY=8BITMIME to ESMTP listener (default) ๐Ÿšซ8๏ธโƒฃ
  • no dropstatus โ€” Do not drop Status headers (default) ๐Ÿšซ๐Ÿ—‘๏ธ
  • no dropdelivered โ€” Do not drop Delivered-To headers (default) ๐Ÿšซ๐Ÿ—‘๏ธ
  • no mimedecode โ€” Do not convert quoted-printable to 8-bit in MIME messages (default) ๐Ÿšซ๐Ÿ”„
  • no idle โ€” Do not idle waiting for new messages after each poll (IMAP only) ๐Ÿšซ๐Ÿ˜ด
  • limit, -l โ€” Set message size limit ๐Ÿ“
  • warnings, -w โ€” Set message size warning interval โš ๏ธ
  • batchlimit, -b โ€” Max # messages to forward in single connect ๐Ÿ”ข
  • fetchlimit, -B โ€” Max # messages to fetch in single connect ๐Ÿ”ข
  • fetchsizelimit โ€” Max # message sizes to fetch in single transaction ๐Ÿ”ข
  • fastuidl โ€” Use binary search for first unseen message (POP3 only) ๐Ÿ”
  • expunge, -e โ€” Perform an expunge on every #th message (IMAP and POP3 only) ๐ŸŒช๏ธ
  • properties โ€” String value is ignored by fetchmail (may be used by extension scripts) ๐Ÿ‘ป

All user options must begin with a user description (user or username option) and follow all server descriptions and options. like, order matters, bestie. ๐Ÿ“‹โœจ

In the .fetchmailrc file, the 'envelope' string argument may be preceded by a whitespace-separated number. This number, if specified, is the number of such headers to skip over (that is, an argument of 1 selects the second header of the given type). This is sometimes useful for ignoring bogus envelope headers created by an ISP's local delivery agent or internal forwards (through mail inspection systems, for instance). ๐Ÿ•ต๏ธโ™€๏ธ


โœจ Keywords Not Corresponding To Option Switches โœจ

The 'folder' and 'smtphost' options (unlike their command-line equivalents) can take a space- or comma-separated list of names following them. ๐Ÿ—’๏ธ

All options correspond to the obvious command-line arguments, except the following: 'via', 'interval', 'aka', 'is', 'to', 'dns'/'no dns', 'checkalias'/'no checkalias', 'password', 'preconnect', 'postconnect', 'localdomains', 'stripcr'/'no stripcr', 'forcecr'/'no forcecr', 'pass8bits'/'no pass8bits' 'dropstatus/no dropstatus', 'dropdelivered/no dropdelivered', 'mimedecode/no mimedecode', 'no idle', and 'no envelope'. (yes that's the whole menu, don't @ me) ๐Ÿฝ๏ธ

The 'via' option is for if you want to have more than one configuration pointing at the same site. If it is present, the string argument will be taken as the actual DNS name of the mail server host to query. This will override the argument of poll, which can then simply be a distinct label for the configuration (e.g., what you would give on the command line to explicitly query this host). ๐Ÿท๏ธโžก๏ธ๐Ÿ–ฅ๏ธ

The 'interval' option (which takes a numeric argument) allows you to poll a server less frequently than the basic poll interval. If you say 'interval N' the server this option is attached to will only be queried every N poll intervals. ๐Ÿ•ฐ๏ธ (she's low maintenance, she shows up every Nth time)


๐ŸŒˆ Singledrop versus Multidrop options ๐ŸŒˆ

Please ensure you read the section titled THE USE AND ABUSE OF MULTIDROP MAILBOXES if you intend to use multidrop mode. fr fr, go read it. ๐Ÿ“–๐Ÿ‘€

The 'is' or 'to' keywords associate the following local (client) name(s) (or server-name to client-name mappings separated by =) with the mail server user name in the entry. If an is/to list has '*' as its last name, unrecognized names are simply passed through. Note that until fetchmail version 6.3.4 inclusively, these lists could only contain local parts of user names (fetchmail would only look at the part before the @ sign). fetchmail versions 6.3.5 and newer support full addresses on the left hand side of these mappings, and they take precedence over any 'localdomains', 'aka', 'via' or similar mappings. ๐ŸŽ€ (glow-up of the century ngl)

A single local name can be used to support redirecting your mail when your username on the client machine is different from your name on the mail server. When there is only a single local name, mail is forwarded to that local username regardless of the message's Received, To, Cc, and Bcc headers. In this case, fetchmail never does DNS lookups. ๐Ÿ’Œ

When there is more than one local name (or name mapping), fetchmail looks at the envelope header, if configured, and otherwise at the Received, To, Cc, and Bcc headers of retrieved mail (this is 'multidrop mode'). It looks for addresses with host name parts that match your poll name or your 'via', 'aka' or 'localdomains' options, and usually also for host name parts which DNS tells it are aliases of the mail server. See the discussion of 'dns', 'checkalias', 'localdomains', and 'aka' for details on how matching addresses are handled. ๐Ÿงš

If fetchmail cannot match any mail server usernames or localdomain addresses, the mail will be bounced. Normally it will be bounced to the sender, but if the 'bouncemail' global option is off, the mail will go to the local postmaster instead. (see the 'postmaster' global option). See also BUGS. ๐Ÿ˜ญ๐Ÿ’”

The dns option (normally on, bestie, keep it that way unless you know what you're doing โœจ) controls the way addresses from multidrop mailboxes get checked. When it's on, it enables the logic that checks each host address which does not match an aka or localdomains declaration by looking it up with DNS. And when a mail server username gets recognized attached to a matching host name part, its local mapping gets added to the list of local recipients. Slay.

The checkalias option (normally off) extends the lookups that the dns keyword does in multidrop mode, giving you a way to cope with remote MTAs that identify themselves using their canonical name while they're being polled using an alias. Like, when such a server is polled, the checks to extract the envelope address fail, and fetchmail reverts to delivery using the To/Cc/Bcc headers (peep below at 'Header versus Envelope addresses' ๐Ÿ‘€). Specifying this option tells fetchmail to retrieve all the IP addresses associated with both the poll name and the name the remote MTA uses, then compare those IP addresses. This comes in handy when the remote server undergoes frequent canonical name changes that would otherwise require you to go edit your rcfile (ugh, no thanks ๐Ÿ’…). Heads up tho: checkalias has no effect if no dns is specified in the rcfile.

The aka option is for use with multidrop mailboxes. It lets you pre-declare a list of DNS aliases for a server. It's an optimization hack that lets you trade space for speed ๐Ÿƒโ™€๏ธ. When fetchmail, while processing a multidrop mailbox, grovels through message headers looking for names of the mail server, pre-declaring the common ones can save it from having to do DNS lookups. Note: the names you give as arguments to aka are matched as suffixes โ€” if you specify (say) aka netaxs.com, this will match not just a host name netaxs.com, but any host name that ends with .netaxs.com; such as (say) pop3.netaxs.com and mail.netaxs.com.

The localdomains option lets you declare a list of domains which fetchmail should consider local. When fetchmail is parsing address lines in multidrop modes, and a trailing segment of a host name matches a declared local domain, that address is passed through to the listener or MDA unaltered (local-name mappings are not applied).

If you're using localdomains, you may also need to specify no envelope, which disables fetchmail's normal attempt to deduce an envelope address from the Received line or X-Envelope-To header or whatever header has been previously set by envelope. If you set no envelope in the defaults entry, it's possible to undo that in individual entries by using envelope <string>. And as a special case: envelope "Received" restores the default parsing of Received lines. ๐ŸŽ€

The password option requires a string argument, which is the password to be used with the entry's server. Keep it secret, keep it safe ๐Ÿ’–

The preconnect keyword lets you specify a shell command to be executed just before each time fetchmail establishes a mail server connection. This may be useful if you're attempting to set up secure POP connections with the aid of ssh(1). If the command returns a nonzero status, the poll of that mail server will be aborted โš ๏ธ.

Similarly, the postconnect keyword similarly lets you specify a shell command to be executed just after each time a mail server connection is taken down.

The forcecr option controls whether lines terminated by LF only are given CRLF termination before forwarding. Strictly speaking, RFC821 requires this, but few MTAs enforce the requirement, so this option is normally off (only one such MTA, qmail, is in significant use at time of writing).

The stripcr option controls whether carriage returns are stripped out of retrieved mail before it's forwarded. It's normally not necessary to set this, because it defaults to on (CR stripping enabled) when there is an MDA declared, but off (CR stripping disabled) when forwarding is via SMTP. And if stripcr and forcecr are both on, stripcr will override.

The pass8bits option exists to cope with Microsoft mail programs that stupidly slap a "Content-Transfer-Encoding: 7bit" on literally everything ๐Ÿ’€. With this option off (the default) and such a header present, fetchmail declares BODY=7BIT to an ESMTP-capable listener; this causes problems for messages actually using 8-bit ISO or KOI-8 character sets, which will get garbled by having the high bits of all characters stripped. If pass8bits is on, fetchmail is forced to declare BODY=8BITMIME to any ESMTP-capable listener. If the listener is 8-bit-clean (as all the major ones now are), the right thing will probably result. Probably. ๐Ÿ˜Œ

The dropstatus option controls whether nonempty Status and X-Mozilla-Status lines are retained in fetched mail (the default) or discarded. Retaining them lets your MUA see what messages (if any) were marked seen on the server. On the other hand, it can confuse some new-mail notifiers, which assume that anything with a Status line in it has been seen. (Note: the empty Status lines inserted by some buggy POP servers are unconditionally discarded.)

The dropdelivered option controls whether Delivered-To headers will be kept in fetched mail (the default) or discarded. These headers are added by qmail and Postfix mail servers in order to avoid mail loops, but they may get in your way if you try to "mirror" a mail server within the same domain. Use with caution โš ๏ธ.

The mimedecode option controls whether MIME messages using the quoted-printable encoding are automatically converted into pure 8-bit data. If you're delivering mail to an ESMTP-capable, 8-bit-clean listener (that includes all of the major MTAs like sendmail), then this will automatically convert quoted-printable message headers and data into 8-bit data, making it easier to understand when reading mail. If your e-mail programs know how to deal with MIME messages, then this option is not needed. The mimedecode option is off by default, because doing RFC2047 conversion on headers throws away character-set information and can lead to bad results if the encoding of the headers differs from the body encoding. ๐Ÿ˜ญ

The idle option is intended to be used with IMAP servers supporting the RFC2177 IDLE command extension, but does not strictly require it. If it's enabled, and fetchmail detects that IDLE is supported, an IDLE will be issued at the end of each poll. This will tell the IMAP server to hold the connection open and notify the client when new mail is available. If IDLE is not supported, fetchmail will simulate it by periodically issuing NOOP. If you need to poll a link frequently, IDLE can save bandwidth by eliminating TCP/IP connects and LOGIN/LOGOUT sequences ๐Ÿ‘‘. On the other hand, an IDLE connection will eat almost all of your fetchmail's time, because it will never drop the connection and allow other polls to occur unless the server times out the IDLE. It also doesn't work with multiple folders; only the first folder will ever be polled. ๐Ÿ™ˆ

The properties option is an extension mechanism. It takes a string argument, which is ignored by fetchmail itself. The string argument may be used to store configuration information for scripts which require it. In particular, the output of the --configdump option will make properties associated with a user entry readily available to a Python script. ๐Ÿ

๐ŸŒˆ Miscellaneous Run Control Options ๐ŸŒˆ

The words here and there have useful English-like significance. Normally user eric is esr would mean that mail for the remote user eric is to be delivered to esr, but you can make this clearer by saying user eric there is esr here, or reverse it by saying user esr here is eric there

Legal protocol identifiers for use with the protocol keyword are:

auto (or AUTO) (legacy, to be removed from future release)
pop2 (or POP2) (legacy, to be removed from future release)
pop3 (or POP3)
sdps (or SDPS)
imap (or IMAP)
apop (or APOP)
kpop (or KPOP)

Legal authentication types are any, password, kerberos, kerberos_v4, kerberos_v5 and gssapi, cram-md5, otp, msn (only for POP3), ntlm, implicit, external (only IMAP). The password type specifies authentication by normal transmission of a password (the password may be plain text or subject to protocol-specific encryption, as in CRAM-MD5); kerberos tells fetchmail to try to get a Kerberos ticket at the start of each query instead, and send an arbitrary string as the password; and gssapi tells fetchmail to use GSSAPI authentication. See the description of the auth keyword for more. โœจ

Specifying kpop sets POP3 protocol over port 1109 with Kerberos V4 authentication. These defaults may be overridden by later options.

There are some global option statements: set logfile followed by a string sets the same global specified by --logfile. A command-line --logfile option will override this. Note that --logfile is only effective if fetchmail detaches itself from the terminal and the logfile already exists before fetchmail is run, and it overrides --syslog in this case. Also, set daemon sets the poll interval as --daemon does. This can be overridden by a command-line --daemon option; in particular --daemon 0 can be used to force foreground operation. The set postmaster statement sets the address to which multidrop mail defaults if there are no local matches. Finally, set syslog sends log messages to syslogd(8). ๐Ÿซถ

๐Ÿ’€ DEBUGGING FETCHMAIL ๐Ÿ’€

๐Ÿ˜ญ Fetchmail crashing ๐Ÿ˜ญ

Okay bestie, so there are a bunch of ways fetchmail can "crash" โ€” like, just full-on stop doing its thing suddenly and with zero warning. A "crash" is usually referring to an error condition that the software did not handle by itself. And the most famous little gremlin of a failure mode? The "segmentation fault", aka "signal 11", aka "SIGSEGV", aka just "segfault" if we're being casual about it. ๐Ÿ’€

Now these can be caused by hardware problems or by software problems, and the vibes are very different:

  • Software-induced segfaults โ€” usually reproducible easily and in the same place every time.
  • Hardware-induced segfaults โ€” can literally just go away if the computer is rebooted, or powered off for a few hours ๐Ÿ˜ญ, and can happen in random locations even if you use the software the exact same way.

For solving hardware-induced segfaults: find the faulty component and repair or replace it. The Sig11 FAQ may help you with the details, bestie.

For solving software-induced segfaults: the developers may need a "stack backtrace". ๐Ÿ‘‘

๐Ÿงš Enabling fetchmail core dumps ๐Ÿงš

By default, fetchmail suppresses core dumps because โ€” no cap โ€” these might contain passwords and other sensitive info. ๐Ÿ™ˆ For debugging fetchmail crashes though, obtaining a "stack backtrace" from a core dump is often the quickest way to solve the problem. And when you post your problem on a mailing list, the developers may ask you for a "backtrace". So here's the whole process, step by step:

  1. To get useful backtraces, fetchmail needs to be installed without getting stripped of its compilation symbols. Unfortunately, most binary packages that get installed are stripped, and core files from symbol-stripped programs are worthless. So you may need to recompile fetchmail. On many systems, you can type:
file `which fetchmail`

to find out if fetchmail was symbol-stripped or not. If yours was unstripped โ€” fine, proceed โœจ โ€” if it was stripped, you need to recompile the source code first. You do not usually need to install fetchmail in order to debug it.

  1. The shell environment that starts fetchmail needs to enable core dumps. The key is the "maximum core (file) size", which can usually be configured with a tool named "limit" or "ulimit". See the documentation for your shell for the details. In the popular bash shell, this:
ulimit -Sc unlimited

will allow the core dump. ๐Ÿ’…

  1. You need to tell fetchmail, too, to allow core dumps. To do this, run fetchmail with the -d0 -v options. It is often easier to also add --nosyslog -N as well.

Finally, you need to reproduce the crash. You can just start fetchmail from the directory where you compiled it by typing ./fetchmail, so the complete command line will start with:

./fetchmail -Nvd0 --nosyslog

and perhaps list your other options.

After the crash, run your debugger to obtain the core dump. The debugger will often be GNU GDB, and you can then type (adjust paths as necessary):

gdb ./fetchmail fetchmail.core

and then, after GDB has started up and read all its files, type:

backtrace full

save the output (copy & paste will do โ€” the backtrace will be read by a human ๐Ÿซถ) and then type quit to leave gdb.

Note: on some systems, the core files have different names โ€” they might contain a number instead of the program name, or number and name โ€” but it will usually have "core" as part of their name, so you can still find them. iykyk.

โœจ INTERACTION WITH RFC 822 โœจ

When trying to determine the originating address of a message, fetchmail looks through headers in this exact order:

Return-Path:
Resent-Sender: (ignored if it does not contain an @ or !)
Sender: (ignored if it does not contain an @ or !)
Resent-From:
From:
Reply-To:
Apparently-From:

The originating address is used for logging, and to set the MAIL FROM address when forwarding to SMTP. This order is intended to cope gracefully with receiving mailing list messages in multidrop mode. The intent is that if a local address does not exist, the bounce message will not be returned blindly to the author or to the list itself, but rather to the list manager โ€” which is, lowkey, way less annoying. ๐Ÿ˜Œ

In multidrop mode, destination headers are processed like this: First, fetchmail looks for the header specified by the 'envelope' option in order to determine the local recipient address. If the mail is addressed to more than one recipient, the Received line will not contain any information regarding recipient addresses. ๐Ÿ™ˆ

Then fetchmail looks for the Resent-To:, Resent-Cc:, and Resent-Bcc: lines. If they exist, they should contain the final recipients and have precedence over their To:/Cc:/Bcc: counterparts. If the Resent-* lines do not exist, the To:, Cc:, Bcc: and Apparently-To: lines are looked for. (The presence of a Resent-To: is taken to imply that the person referred by the To: address has already received the original copy of the mail.) ๐Ÿ‘‘


๐ŸŽ€ CONFIGURATION EXAMPLES ๐ŸŽ€

Okay so โ€” note that although there are password declarations in a good many of the examples below, this is mainly for illustrative purposes. We recommend stashing account/password pairs in your $HOME/.netrc file, where they can be used not just by fetchmail but by ftp(1) and other programs too. โœจ

The basic format is:

poll SERVERNAME protocol PROTOCOL username NAME password PASSWORD

Example:

poll pop.provider.net protocol pop3 username "jsmith" password "secret1"

Or, using some abbreviations:

poll pop.provider.net proto pop3 user "jsmith" password "secret1"

Multiple servers may be listed:

poll pop.provider.net proto pop3 user "jsmith" pass "secret1"
poll other.provider.net proto pop2 user "John.Smith" pass "My^Hat"

Here is the same version with more whitespace and some noise words:

poll pop.provider.net proto pop3
     user "jsmith", with password secret1, is "jsmith" here;
poll other.provider.net proto pop2:
     user "John.Smith", with password "My^Hat", is "John.Smith" here;

If you need to include whitespace in a parameter string or start the latter with a number, enclose the string in double quotes. Thus:

poll mail.provider.net with proto pop3:
     user "jsmith" there has password "4u but u cannot krak this"
     is jws here and wants mda "/bin/mail"

You may have an initial server description headed by the keyword 'defaults' instead of 'poll' followed by a name. Such a record is interpreted as defaults for all queries to use. It may be overwritten by individual server descriptions. So, you could write:

defaults proto pop3
     user "jsmith"
poll pop.provider.net
     pass "secret1"
poll mail.provider.net
     user "jjsmith" there has password "secret2"

It is possible to specify more than one user per server. The 'user' keyword leads off a user description, and every user specification in a multi-user entry must include it. Here is an example:

poll pop.provider.net proto pop3 port 3111
     user "jsmith" with pass "secret1" is "smith" here
     user jones with pass "secret2" is "jjones" here keep

This associates the local username 'smith' with the pop.provider.net username 'jsmith', and the local username 'jjones' with the pop.provider.net username 'jones'. Mail for 'jones' is kept on the server after download. ๐Ÿ’…

Here is what a simple retrieval configuration for a multidrop mailbox looks like:

poll pop.provider.net:
     user maildrop with pass secret1 to golux 'hurkle'='happy' snark here

This says that the mailbox of account 'maildrop' on the server is a multidrop box, and that messages in it should be parsed for the server user names 'golux', 'hurkle', and 'snark'. It further specifies that 'golux' and 'snark' have the same name on the client as on the server, but mail for server user 'hurkle' should be delivered to client user 'happy'. โœจ

Note that fetchmail, until version 6.3.4, did NOT allow full user@domain specifications here โ€” these would never match. Fetchmail 6.3.5 and newer support user@domain specifications on the left-hand side of a user mapping. ๐Ÿ‘‘

Here is an example of another kind of multidrop connection:

poll pop.provider.net localdomains loonytoons.org toons.org
     envelope X-Envelope-To
     user maildrop with pass secret1 to * here

This also says that the mailbox of account 'maildrop' on the server is a multidrop box. It tells fetchmail that any address in the loonytoons.org or toons.org domains (including sub-domain addresses like 'joe@daffy.loonytoons.org') should be passed through to the local SMTP listener without modification.

โš ๏ธ Be careful of mail loops if you do this! fr fr.

Here is an example configuration using ssh and the plugin option. The queries are made directly on the stdin and stdout of imapd via ssh. Note that in this setup, IMAP authentication can be skipped. ๐Ÿ˜ฎ

poll mailhost.net with proto imap:
     plugin "ssh %h /usr/sbin/imapd" auth implicit;
     user esr is esr here

๐Ÿ’… THE USE AND ABUSE OF MULTIDROP MAILBOXES ๐Ÿ’…

ok bestie, listen. the multiple-local-recipients feature is cute but use it with caution โ€” it can absolutely bite you. ๐Ÿฆˆ

and real talk: all the multidrop features are simply not effective in ETRN and ODMR modes. no cap.

also heads up โ€” in multidrop mode, duplicate mails may get suppressed. a piece of mail counts as duplicate if it does not have a discernible envelope recipient address, has the same header as the message right before it, and has more than one addressee. you get these runs of messages when copies of a message addressed to multiple users get delivered to a multidrop box. (to be super precise: fetchmail 6.2.5 through 6.4.X use an MD5 hash of the raw message header, and only fetchmail 6.4.16+ actually document this properly. Fetchmail 5.0.8 (1999-09-14) through 6.2.4 used only the Message-ID header. 5.0.7 and older did not suppress duplicates at all.)

ngl, this duplication killer code checking the entire header is very restrictive and may not suppress many duplicates in practice โ€” like if some X-Original-To or Delivered-To header differs. and that's intentional and correct in those situations: wherever envelope information is available, it should be used for reliable delivery of mailing list and blind carbon copy (Bcc) messages. check the subsection Duplicate suppression below for ideas. โœจ

๐Ÿฆ‹ Header versus Envelope addresses

the fundamental problem, bestie, is this: by having your mail server toss several people's mail into a single maildrop box, you may have thrown away potentially vital information about who each piece of mail was actually addressed to. we're talking about the envelope address, as opposed to the header addresses in the RFC822 To/Cc headers โ€” and btw the Bcc is not available at the receiving end. ๐Ÿ˜ญ that envelope address is the one you need to reroute mail properly.

sometimes fetchmail can deduce the envelope address. if the mail server MTA is sendmail and the item of mail had just one recipient, the MTA will have written a by/for clause that gives the envelope addressee into its Received header. but this does not work reliably for other MTAs, and not if there's more than one recipient either. by default, fetchmail looks for envelope addresses in these lines; you can restore this default with -E "Received" or 'envelope Received'. ๐Ÿ’…

as a better alternative, some SMTP listeners and/or mail servers insert a header in each message containing a copy of the envelope addresses. this header (when it exists) is often 'X-Original-To', 'Delivered-To' or 'X-Envelope-To'. fetchmail's assumption about this can be changed with the -E or 'envelope' option. but note: writing an envelope header like this exposes the names of recipients (including blind-copy recipients) to all receivers of the messages, so the upstream must store one copy of the message per recipient to avoid becoming a privacy problem. ๐Ÿ™ˆ

Postfix, since version 2.0, writes an X-Original-To: header which contains a copy of the envelope as it was received. ๐Ÿ‘‘

Qmail and Postfix generally write a 'Delivered-To' header upon delivering the message to the mail spool, and use it to avoid mail loops. Qmail virtual domains however will prefix the user name with a string that normally matches the user's domain. to remove this prefix you can use the -Q or 'qvirtual' option.

sometimes, unfortunately, neither of these methods works. ๐Ÿ˜ญ that is the point when you should contact your ISP and ask them to provide such an envelope header โ€” and you should not use multidrop in this situation. when they all fail, fetchmail must fall back on the contents of To/Cc headers (Bcc headers are not available โ€” see below) to try to determine recipient addressees, and bestie those are unreliable. in particular, mailing-list software often ships mail with only the list broadcast address in the To: header.

โš ๏ธ note that a future version of fetchmail may remove To/Cc parsing!

when fetchmail cannot deduce a recipient address that is local, and the intended recipient address was anyone other than fetchmail's invoking user, mail will get lost. ๐Ÿ’€ that's exactly what makes the multidrop feature risky without proper envelope information.

a related problem: when you blind-copy a mail message, the Bcc information is carried only as envelope address (it's removed from the headers by the sending mail server, so fetchmail can only see it if there's an X-Envelope-To header). so blind-copying to someone who gets mail over a fetchmail multidrop link will fail unless the mail server host routinely writes X-Envelope-To or an equivalent header into messages in your maildrop. ๐Ÿ˜ค

in conclusion, mailing lists and Bcc'd mail can only work if the server you are fetching from:

  1. stores one copy of the message per recipient in your domain, and
  2. records the envelope information in a special header (X-Original-To, Delivered-To, X-Envelope-To).

๐ŸŒธ Good Ways To Use Multidrop Mailboxes

multiple local names can be used to administer a mailing list from the client side of a fetchmail collection. suppose your name is 'esr', and you want to both pick up your own mail and maintain a mailing list called (say) "fetchmail-friends", and you want to keep the alias list on your client machine. so valid. โœจ

on your server, you can alias 'fetchmail-friends' to 'esr'; then, in your .fetchmailrc, declare 'to esr fetchmail-friends here'. then, when mail including 'fetchmail-friends' as a local address gets fetched, the list name will be appended to the list of recipients your SMTP listener sees. therefore it will undergo alias expansion locally. be sure to include 'esr' in the local alias expansion of fetchmail-friends, or you will never see mail sent only to the list. also be sure that your listener has the "me-too" option set (sendmail's -oXm command-line option or OXm declaration) so your name is not removed from alias expansions in messages you send. ๐Ÿ’…

this trick is not without its problems though. you'll start seeing this when a message comes in that's addressed only to a mailing list you do not have declared as a local name. each such message will feature an 'X-Fetchmail-Warning' header which is generated because fetchmail cannot find a valid local name in the recipient addresses. such messages default (as was described above) to being sent to the local user running fetchmail, but the program has no way to know that this is actually the right thing. ๐Ÿ™ˆ

๐Ÿ’€ Bad Ways To Abuse Multidrop Mailboxes

multidrop mailboxes and fetchmail serving multiple users in daemon mode do not mix. the problem, again, is mail from mailing lists, which typically does not have an individual recipient address on it. unless fetchmail can deduce an envelope address, such mail will only go to the account running fetchmail (probably root). also, blind-copied users are very likely never to see their mail at all. ๐Ÿ˜ญ

if you are tempted to use fetchmail to retrieve mail for multiple users from a single mail drop via POP or IMAP โ€” think again (and reread the section on header and envelope addresses above). it would be smarter to just let the mail sit in the mail server's queue and use fetchmail's ETRN or ODMR modes to trigger SMTP sends periodically (of course, this means you have to poll more frequently than the mail server's expiry period). if you cannot arrange this, try setting up a UUCP feed.

if you absolutely must use multidrop for this purpose, make sure your mail server writes an envelope-address header that fetchmail can see. otherwise you will lose mail and it will come back to haunt you. ๐Ÿ‘ป

๐Ÿฆ‹ Speeding Up Multidrop Checking

normally, when multiple users are declared, fetchmail extracts recipient addresses as described above and checks each host part with DNS to see if it's an alias of the mail server. if so, the name mappings described in the "to ... here" declaration are done and the mail locally delivered.

this is a convenient but also slow method. ๐ŸŒ to speed it up, pre-declare mail server aliases with 'aka'; these are checked before DNS lookups are done. if you are certain your aka list contains all DNS aliases of the mail server (and all MX names pointing at it โ€” note this may change in a future version) you can declare 'no dns' to suppress DNS lookups entirely and only match against the aka list. slay, efficiency. โšก

๐ŸŽ€ Duplicate suppression on multidrop

if fetchmail's duplicate suppression code does not kick in for your multidrop mail account, other options include using sieve, or for instance Courier's maildrop package (and in particular, its reformail program with the -D option) as the delivery agent (either from fetchmail, or from your local mail server that fetchmail injects into). ๐Ÿงš


๐ŸŒˆ SOCKS ๐ŸŒˆ

support for socks4/5 is a compile time configuration option. once compiled in, fetchmail will always use the socks libraries and configuration on your system โ€” there are no run-time switches in fetchmail. but you can still configure SOCKS: you can specify which SOCKS configuration file is used in the SOCKS_CONF environment variable. โœจ

for instance, if you wanted to bypass the SOCKS proxy altogether and have fetchmail connect directly, you could just pass SOCKS_CONF=/dev/null in the environment, for example (add your usual command line options โ€” if any โ€” to the end of this line):

env SOCKS_CONF=/dev/null fetchmail

โœจ EXIT CODES โœจ

ok so if you're scripting fetchmail (and bestie, you should be), this is the part you actually care about ๐Ÿ’… every time a connection wraps up, fetchmail hands back an exit status code telling you what went down. it's giving "receipts".

here's the full tea, code by code:

  1. 0 โ€” one or more messages were successfully retrieved (or, if you used the -c option, they were found just waiting there but not actually pulled). iconic. no notes. ๐Ÿ‘‘
  2. 1 โ€” there was no mail waiting to be retrieved. (there might legit be old mail still sitting on the server, just nothing selected for retrieval.) if you don't want "no mail" to count as an error โ€” say, for cron jobs โ€” use a POSIX-compliant shell and slap this on the end of your fetchmail command line:
|| [ $? -eq 1 ]

heads up though, this leaves 0 untouched, maps 1 to 0, and maps all other codes to 1. also peep item #C8 in the FAQ. ๐Ÿซถ

  1. 2 โ€” an error got hit while trying to open a socket to retrieve mail. if you don't even know what a socket is, don't stress โ€” just treat this as an "unrecoverable error". this can also fire because a protocol fetchmail wants to use isn't listed in /etc/services. ๐Ÿ™ˆ
  2. 3 โ€” the user authentication step failed. usually this means a bad user-id, password, or APOP id was given. or it might mean you tried running fetchmail somewhere it didn't have standard input attached to a terminal, so it couldn't prompt you for a missing password. awkward. ๐Ÿ˜ญ
  3. 4 โ€” some kind of fatal protocol error was detected.
  4. 5 โ€” there was a syntax error in the arguments to fetchmail, or a pre- or post-connect command failed.
  5. 6 โ€” the run control file had bad permissions. ๐Ÿšซ
  6. 7 โ€” there was an error condition reported by the server. can also fire if fetchmail timed out while waiting for the server. โณ
  7. 8 โ€” client-side exclusion error. this means fetchmail either found another copy of itself already running, or failed in a way where it's not sure whether another copy is running. the suspense. ๐Ÿ’€
  8. 9 โ€” the user authentication step failed because the server responded "lock busy". try again after a brief pause! โš ๏ธ this error is not implemented for all protocols, nor for all servers. if it's not implemented for your server, "3" gets returned instead (see above). may get returned when talking to qpopper or other servers that can respond with "lock busy" or some similar text containing the word "lock".
  9. 10 โ€” the fetchmail run failed while trying to do an SMTP port open or transaction.
  10. 11 โ€” fatal DNS error. fetchmail hit an error while doing a DNS lookup at startup and couldn't proceed.
  11. 12 โ€” BSMTP batch file could not be opened.
  12. 13 โ€” poll terminated by a fetch limit (peep the --fetchlimit option).
  13. 14 โ€” server busy indication.
  14. 23 โ€” internal error. you should see a message on standard error with details.

24 - 26, 28, 29. 24 - 26, 28, 29 โ€” these are internal codes and should not appear externally. (iykyk, if you see one, something is weird.)

--

when fetchmail queries more than one host, the return status is 0 if any query successfully retrieved mail. otherwise the returned error status is that of the last host queried. periodt. โœจ

๐Ÿ“ FILES ๐Ÿ“

  • ~/.fetchmailrc, $HOME/.fetchmailrc, $HOME_ETC/.fetchmailrc, $FETCHMAILHOME/fetchmailrc โ€” the default run control file (its location can be overridden with environment variables). this is the whole vibe of your setup, fr. ๐Ÿ’–
  • ~/.fetchids, $HOME/.fetchids, $HOME_ETC/.fetchids, $FETCHMAILHOME/.fetchids โ€” default location of the file recording the last message UIDs seen per host. (location can be overridden with environment variables)
  • ~/.fetchmail.pid, $HOME/.fetchmail.pid, $HOME_ETC/.fetchmail.pid, $FETCHMAILHOME/fetchmail.pid โ€” default location of the lock file (sometimes called pidfile or PID file, see option pidfile) that helps prevent concurrent runs (non-root mode). (location can be overridden with environment variables)
  • ~/.netrc, $HOME/.netrc, $HOME_ETC/.netrc โ€” your FTP run control file, which (if present) will be searched for passwords as a last resort before prompting for one interactively. (location can be overridden with environment variables) ๐Ÿ“
  • /var/run/fetchmail.pid โ€” lock file (pidfile) to help prevent concurrent runs (root mode, Linux systems).
  • /etc/fetchmail.pid โ€” lock file (pidfile) to help prevent concurrent runs (root mode, systems without /var/run).

๐ŸŒˆ ENVIRONMENT ๐ŸŒˆ

fetchmail's behavior can be altered by handing it environment variables. some of them might tweak libraries fetchmail links against, like OpenSSL. โš ๏ธ important: in daemon mode, you'll need to quit the background daemon process and start a fresh fetchmail daemon before environment changes actually take effect. no cap.

  • FETCHMAILHOME โ€” if this env var is set to a valid and existing directory name, fetchmail will read $FETCHMAILHOME/fetchmailrc (no dot in this case), $FETCHMAILHOME/.fetchids (keeps its dot) and $FETCHMAILHOME/fetchmail.pid (no dot) instead of from the user's home directory. the .netrc file, though, is always looked for in the invoking user's home directory (or $HOME_ETC) regardless of what FETCHMAILHOME is set to. ๐Ÿ 
  • FETCHMAILUSER โ€” if set, it's used as the name of the calling user (the default local name) for stuff like mailing error notifications. otherwise, if either the LOGNAME or USER variable is set correctly (like, the corresponding UID matches the session user ID), then that name becomes the default local name. otherwise getpwuid(3) must be able to retrieve a password entry for the session ID. (this elaborate logic is designed to handle the case of multiple names per user ID gracefully โ€” very demure, very mindful.)
  • FETCHMAIL_DISABLE_CBC_IV_COUNTERMEASURE โ€” (since v6.3.22): if this env var is set and not empty, fetchmail will disable a countermeasure against an SSL CBC IV attack (by setting SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS). ๐Ÿšจ this is a security risk, but it may be necessary for connecting to certain non-standards-conforming servers. see fetchmail's NEWS file and fetchmail-SA-2012-01.txt for details. earlier fetchmail versions (v6.3.21 and older) used to disable this countermeasure, but v6.3.22 no longer does that as a safety precaution.
  • FETCHMAIL_POP3_FORCE_RETR โ€” (since v6.3.9): if this env var is defined at all (even if empty), fetchmail will forgo the POP3 TOP command and always use RETR. this can be used as a workaround when TOP doesn't work properly.
  • FETCHMAIL_INCLUDE_DEFAULT_X509_CA_CERTS โ€” (since v6.3.17): if this env var is set and not empty, fetchmail will always load the default X.509 trusted certificate locations for SSL/TLS CA certificates, even if --sslcertfile and --sslcertpath are given. those latter locations take precedence over the system default locations. this is useful in case there are broken certificates in the system directories and the user has no administrator privileges to remedy the problem. ๐ŸŽ€
  • FETCHMAIL_WOLFSSL_DEBUG โ€” (since v6.4.25): if fetchmail is compiled and linked with wolfSSL, if wolfSSL was built with --enable-debug, and if this env var is set and not empty, then enable wolfSSL's debug mode. this will emit huge amounts of debug output to stderr. ๐Ÿ’€ (you've been warned.)
  • HOME โ€” (documented since 6.4.1): this variable is normally set to the user's home directory. if it's set to a different directory than what's in the password database, HOME takes precedence.
  • HOME_ETC โ€” (documentation corrected to match behaviour of code since 6.4.1): if the HOME_ETC variable is set, it will override fetchmail's idea of $HOME, i.e. fetchmail will read .fetchmailrc, .fetchids, .fetchmail.pid and .netrc from $HOME_ETC instead of $HOME (or, if HOME is also unset, from the passwd file's home directory location). if HOME_ETC and FETCHMAILHOME are both set, FETCHMAILHOME takes precedence and HOME_ETC will be ignored. ๐Ÿ’œ
  • SOCKS_CONF โ€” (only if SOCKS support is compiled in) this variable is used by the socks library to find out which configuration file it should read. set this to /dev/null to bypass the SOCKS proxy. ๐Ÿงฆ
  • SSL_CERT_DIR โ€” (with truly OpenSSL 3.0 compatible library): overrides OpenSSL's idea of the default trust directory or path (which contains individual certificate files and hashed symlinks), see the SSL_CTX_set_default_verify_paths(3) manual page for details โ€” it may be in the openssl development package. if using another library's OpenSSL compatibility interface, this may not work. since this variable only specifies a default value, the option --sslcertpath takes precedence if given. ๐Ÿ”
  • SSL_CERT_FILE โ€” (with truly OpenSSL 3.0 compatible library): overrides OpenSSL's idea of the default trust certificate bundle file (which contains a concatenation of base64-encoded certificates in PEM format), see the SSL_CTX_set_default_verify_paths(3) manual page for details โ€” it may be in the openssl development package. if using another library's OpenSSL compatibility interface, this may not work. since this variable only specifies a default value, the option --sslcertfile takes precedence if given.
  • other system default variables โ€” like TZ or the locale LC_XXX variables โ€” will also influence program behaviour. ๐ŸŒ

๐Ÿšจ SIGNALS ๐Ÿšจ

if a fetchmail daemon is running as root, SIGUSR1 wakes it up from its sleep phase and forces a poll of all non-skipped servers. for compatibility reasons, SIGHUP can also be used in 6.3.X but may not be available in future fetchmail versions. โฐ

if fetchmail is running in daemon mode as non-root, use SIGUSR1 to wake it โ€” this is so that SIGHUP due to logout can retain the default action of killing it. ๐Ÿ’…

running fetchmail in the foreground while a background fetchmail is running will do whichever of these is appropriate to wake it up. ๐Ÿฆ‹

๐Ÿ’€ BUGS, LIMITATIONS, AND KNOWN PROBLEMS ๐Ÿ’€

okay bestie, deep breath, this is the part where we're honest about the red flags. no cap, there's more tea in the NEWS file that shipped with fetchmail than what's listed here, so go read that too.

  • Fetchmail cannot handle user names that contain blanks after a @ character, for instance demonstr@ti on. These are, like, super uncommon and only hurt when you're using UID-based --keep setups, so the 6.X.Y versions of fetchmail will not be fixed. periodt, that's just how it is.
  • Fetchmail cannot handle configurations where you have multiple accounts that use the same server name and the same login. Any user@server combination must be unique. that's the rule. ๐Ÿ‘‘
  • The assumptions that the DNS and in particular the checkalias options make are not often sustainable. For instance, it has become uncommon for an MX server to be a POP3 or IMAP server at the same time. Therefore the MX lookups may go away in a future release. highkey foreshadowing ๐Ÿซ 
  • The mda and plugin options interact badly. In order to collect error status from the MDA, fetchmail has to change its normal signal handling so that dead plugin processes do not get reaped until the end of the poll cycle. This can cause resource starvation if too many zombies accumulate. So either do not deliver to a MDA using plugins or risk being overrun by an army of undead. ๐ŸงŸ literally an undead army, bestie, i cannot
  • The --interface option does not support IPv6 and it is doubtful if it ever will, since there is no portable way to query interface IPv6 addresses. rip to that dream ๐Ÿ’€
  • The RFC822 address parser used in multidrop mode chokes on some @-addresses that are technically legal but bizarre. Strange uses of quoting and embedded comments are likely to confuse it. she's doing her best ๐Ÿ˜ญ
  • In a message with multiple envelope headers, only the last one processed will be visible to fetchmail. the others? gone, reduced to atoms.
  • Use of some of these protocols requires that the program send unencrypted passwords over the TCP/IP connection to the mail server. This creates a risk that name/password pairs might be snaffled with a packet sniffer or more sophisticated monitoring software. Under Linux and FreeBSD, the --interface option can be used to restrict polling to availability of a specific interface device with a specific local or remote IP address, but snooping is still possible if (a) either host has a network device that can be opened in promiscuous mode, or (b) the intervening network link can be tapped. We recommend the use of ssh(1) tunnelling to not only shroud your passwords but encrypt the entire conversation. ๐Ÿ” please bestie, tunnel it.
  • Use of the %F or %T escapes in an mda option could open a security hole, because they pass text manipulable by an attacker to a shell command. Potential shell characters are replaced by '_' before execution. The hole is further reduced by the fact that fetchmail temporarily discards any set-uid privileges it may have while running the MDA. For maximum safety, however, do not use an mda command containing %F or %T when fetchmail is run from the root account itself. ๐Ÿšจ
  • Fetchmail's method of sending bounces due to errors or spam-blocking and spam bounces requires that port 25 of localhost be available for sending mail via SMTP.
  • If you modify ~/.fetchmailrc while a background instance is running and break the syntax, the background instance will die silently. Unfortunately, it cannot die noisily because we do not yet know whether syslog should be enabled. On some systems, fetchmail dies quietly even if there is no syntax error; this seems to have something to do with buggy terminal ioctl code in the kernel. she's just gonna pass away quietly, no goodbye text ๐Ÿ’€
  • The -f - option (reading a configuration from stdin) is incompatible with the plugin option.
  • The 'principal' option only handles Kerberos IV, not V. sorry to that version fr
  • Interactively entered passwords are truncated after 63 characters. If you really need to use a longer password, you will have to use a configuration file. short king ๐Ÿ’…
  • A backslash as the last character of a configuration file will be flagged as a syntax error rather than ignored.
  • The BSMTP error handling is virtually nonexistent and may leave broken messages behind. ๐Ÿ˜ญ
  • Send comments, bug reports, gripes, and the like to the fetchmail-devel list
  • An fetchmail FAQ (in HTML form) is available at the fetchmail home page, it should also accompany your installation. (yes it says "An fetchmail FAQ", we don't make the rules okay)

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Fetchmail is currently maintained by Matthias Andree and Rob Funk with major assistance from Sunil Shetye (for code) and Rob MacGregor (for the mailing lists). the whole squad, iconic.

Most of the code is from Eric S. Raymond. Too many other people to name here have contributed code and patches. fr fr, that's the whole group chat of contributors.

This program is descended from and replaces popclient, by Carl Harris; the internals have become quite different, but some of its interface design is directly traceable to that ancestral program. glow up ๐Ÿฆ‹

This manual page has been improved by Matthias Andree, R. Hannes Beinert, and Hรฉctor Garcรญa.


๐ŸŒธ SEE ALSO ๐ŸŒธ

README, README.SSL, README.SSL-SERVER, The Fetchmail FAQ, mutt(1), elm(1), mail(1), sendmail(8), popd(8), imapd(8), netrc(5), the fetchmail home page, (alternative URI); the maildrop home page.


โญ APPLICABLE STANDARDS โญ

Note that this list is just a collection of references and not a statement as to the actual protocol conformance or requirements in fetchmail. it's a bibliography, not a report card, bestie.

SMTP/ESMTP:

mail:

POP2:

POP3:

APOP:

RPOP:

IMAP2/IMAP2BIS:

IMAP4/IMAP4rev1:

ETRN:

ODMR/ATRN:

OTP: RFC 1938.

LMTP:

GSSAPI:

  • RFC 1508, RFC 1734, Generic Security Service Application Program Interface (GSSโ€API)/Kerberos/Simple Authentication and Security Layer (SASL) Serโ€ vice Names.

TLS: RFC 2595.


and that's the whole manual, bestie! ๐ŸŽ€ this was fetchmail 6.6.9, dated 2025-10-10. go forth and poll your mail, hydrate, and use ssh tunneling. mwah ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from