FETCHMAIL(1)

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

okay so we're reading the FETCHMAIL(1) man page together, and honestly? it's giving legendary. sit down, grab a strawberry, let's go πŸ“

✨ NAME ✨

fetchmail β€” grab your mail off a POP, IMAP, ETRN or ODMR-capable server. that's the whole vibe.


🌈 SYNOPSIS 🌈

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

πŸ¦‹ DESCRIPTION πŸ¦‹

fetchmail is a mail-retrieval and forwarding utility, no cap. it fetches your mail from remote mail servers and forwards it to your local (client) machine's delivery system. then you can handle the retrieved mail with totally normal mail user agents like mutt(1), elm(1) or Mail(1). and get this β€” fetchmail can run in daemon mode to repeatedly poll one or more systems at a specified interval. it's multitasking, it's iconic, it's main character energy. ✨

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, and IMAP4rev1. it can also use the ESMTP ETRN extension and ODMR. (the RFCs describing all these protocols are listed at the end of this manual page. we'll get there.)

so fetchmail is primarily intended to be used over on-demand TCP/IP links (think SLIP or PPP connections), but it may also be useful as a message transfer agent for sites which refuse for security reasons to permit (sender-initiated) SMTP transactions with sendmail. picky sites, honestly, but valid πŸ™ˆ


πŸ’€ DEPRECATION AND CRYPTOGRAPHIC SECURITY WARNINGS πŸ’€

bestie. listen. 😭

several cryptographic algorithms that are referenced by mail standards for authentication were based on MD4 or MD5 or SHA1 algorithms that were developed in 1990, 1991 and 1995 respectively. 30 years later, these are no longer deemed secure, and are considered broken. it's giving expired milk.

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. so it's complicated, we're all doing our best.

the recommendation is to 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. protect the password, protect the peace 🫢

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! πŸ’€
  2. 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. slay.

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). it's cosplaying as an MTA, honestly.

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 and. the ISP must also store one copy of the message per recipient. if either 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. guessing is not a strategy bestie 😭

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. no guessing needed, we love that for them πŸ’…

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. autoprobe is giving ✨psychic✨


πŸ“– 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. (yes the # in there is just a comment marker in the example, iykyk 😌)


πŸ‘‘ 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. command line said it first, periodt.

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. go check it, it matters πŸ‘€

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. they're coming, stay tuned πŸŽ€

⭐ General Options ⭐

  • -? | --help β€” displays option help. cute, quick, useful.
  • -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. it's the "am i actually doing what i think i'm doing" check, and honestly we all need that 🫢

  • -c, --check β€” the "just tell me if there's mail, don't touch anything" option πŸ’… It returns a status code telling you whether mail is waiting, and it does not actually fetch or delete it (peep EXIT CODES below for the codes). Heads up: this turns off daemon mode, because in daemon mode it would be completely useless. It also does not play well with queries to multiple sites, and it straight up does not work with ETRN or ODMR. ⚠️ And it can lie to you: you'll get a false positive if you leave read-but-undeleted mail sitting in your server mailbox and your fetch protocol can't tell kept messages from new ones. Translation: works with IMAP βœ…, does not work with POP2 ❌, and may occasionally flake out under POP3. 😭
  • -s, --silent β€” silent mode 🀫 It suppresses all the progress/status messages that normally get echoed to standard output during a fetch β€” but ngl it does not suppress actual error messages, so you still find out when things go wrong. And --verbose overrides this, so verbose girlies always win. πŸ’–
  • -v, --verbose β€” verbose mode, aka the tea-spilling option πŸ“ Every control message passed between fetchmail and the mail server gets echoed to stdout. Overrides --silent. And if you double it up (-v -v) you get extra diagnostic information printed too. Double the drama, double the info. ✨
  • --nosoftbounce β€” hard bounce mode, and fr this is the one that matters (since v6.3.10, Keyword: set no softbounce, since v6.3.10). All permanent delivery errors cause messages to be deleted from the upstream server, see "no softbounce" below. 😬
  • --softbounce β€” soft bounce mode (since v6.3.10, Keyword: set softbounce, since v6.3.10). All permanent delivery errors cause messages to be left on the upstream server, but only if the protocol supports that. This option is on by default to match historic fetchmail documentation, and is going to be changed to hard bounce mode in the next fetchmail release. So enjoy the soft era while it lasts bestie. 🫢

πŸŽ€ Disposal Options πŸŽ€

  • -a, --all, --fetchall (since v6.3.3) β€” (Keyword: fetchall, since v3.0) β€” Retrieve both old (seen) and new messages from the mail server. The default is to fetch only the messages the server hasn't marked seen. Under POP3, this option also forces the use of RETR rather than TOP. Notes bestie: POP2 retrieval behaves as though --all is always on (see RETRIEVAL FAILURE MODES below) and this option does not work with ETRN or ODMR. Meanwhile, the -a and --all command-line and fetchall rcfile options have been supported for a long time, but the --fetchall command-line option only showed up in v6.3.3. ⭐
  • -k, --keep β€” (Keyword: keep) β€” Keep retrieved messages on the remote mail server πŸ’– Normally messages get deleted from the folder on the mail server once they've been retrieved. Specifying keep makes retrieved messages stay in your folder on the mail server instead. This option does not work with ETRN or ODMR. And IF you're using it with POP3, it's recommended to also specify the --uidl option or the uidl keyword. iykyk. 🧚
  • -K, --nokeep β€” (Keyword: nokeep) β€” Delete retrieved messages from the remote mail server. This forces retrieved mail to be deleted. Super useful if you set a default of keep in your .fetchmailrc and now you're regretting it. This option is forced on with ETRN and ODMR, no takebacks. πŸ’€
  • --moveto <folder> β€” (Keyword: moveto) β€” In IMAP mode, instead of flushing a message, move it to the given IMAP folder instead. 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 is ineffective when --keep is in effect. πŸ™ˆ
  • -F, --flush β€” (Keyword: flush) β€” POP3/IMAP only, and listen closely: 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: this can cause mail loss if you check your mail with other clients than fetchmail, and cause fetchmail to 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 do not specify -k, then fetchmail will automatically delete messages after successful delivery. πŸ’…
  • --limitflush β€” POP3/IMAP only, since version 6.3.0. Delete oversized messages from the mail server before retrieving new messages. The size limit should be separately specified with the --limit option. This option does not work with ETRN or ODMR. 🧹

πŸ’œ Protocol and Query Options πŸ’œ

  • -p <proto>, --proto <proto>, --protocol <proto> β€” (Keyword: proto[col]) β€” Specify the protocol to use when talking to the remote mail server. If no protocol is specified, the default is AUTO. And proto may be one of these gorgeous options:
    • AUTO β€” tries IMAP, POP3, and POP2 (skipping any of these that support wasn't compiled in for).
    • POP2 β€” Post Office Protocol 2 (legacy, 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 in 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 anything addressed to your client machine that's 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) β€” Force UIDL use (effective only with POP3). This 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 are skipped gets logged, unless error logging is done through syslog while running in daemon mode. Note that fetchmail may automatically enable this option depending on upstream server capabilities. Also note that 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) β€” Enable IDLE use (effective only with IMAP). ⚠️ But bestie, read this: 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 had been supported for a long time, the --idle command-line option was added 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 would be possible with regular polls. 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 does not advertise it in its capabilities. This is a dangerous option, use carefully. 🫣
  • --idletimeout (since 6.5.0) β€” (Keyword: idletimeout, since 6.5.0) β€” Set 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 permits you to specify a service name to connect to. You can specify a decimal port number here if your services database lacks the required service-port assignments. See the FAQ item R12 and the --ssl documentation for details. This replaces the older --port option. 🌈
real talk though: 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 to negotiate TLS before sending application data in the clear β€” you may need to specify --ssl on the command line or ssl in your rcfile. no cap. πŸ”
  • --port <portnumber> β€” (Keyword: port) β€” Obsolete version of --service that does not take service names. Note: this option may be removed from a future version. it's giving legacy. πŸ•°οΈ
  • --principal <principal> β€” (Keyword: principal) β€” The principal option permits you to specify a service principal for mutual authentication. This is applicable 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 hang until the TCP connection times out, trying to fetch mail from a down host, which may be very long β€” and ngl that would be particularly annoying for a fetchmail running in the background. There is 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. πŸ“§

Starting with fetchmail 6.3.10, the SMTP client lowkey follows the recommended minimum timeouts from RFC-5321 while it's waiting on the SMTP/LMTP server it's chatting with. You can raise those timeouts even higher, but bestie, you cannot shorten them. Why? Because imagine this nightmare: fetchmail is set up with a short timeout (a minute or less), it ships a long message (many MBytes) to your local MTA, and the MTA takes longer than timeout to say "OK" β€” which it eventually will say. That would mean the mail got delivered properly, but fetchmail can't notice, so it re-fetches that big message over and over again. πŸ’€ Absolutely not. The floor exists so this tragedy never happens to you.

  • --plugin <command> β€” (Keyword: plugin) β€” this 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 gets looked up in $PATH, and you can optionally pass it the host name and port as arguments using "%h" and "%p" respectively β€” heads up tho, the interpolation logic is rather primitive, and these tokens must be bounded by whitespace, the beginning of the string, or the end of the string. Fetchmail writes to the plugin's stdin and reads from the plugin's stdout. 🫢
  • --plugout <command> β€” (Keyword: plugout) β€” literally identical to the plugin option above, but this one is the one used for the SMTP connections. Same energy, different socket. ✨
  • -r <name> | --folder <name> β€” (Keyword: folder[s]) β€” makes a specified non-default mail folder on the mail server (or a comma-separated list of folders) get retrieved. The syntax of the folder name is server-dependent, so don't come for me, ask your server. This option is not available under POP3, ETRN, or ODMR. Sorry bestie, those protocols said no. 🚫
  • --tracepolls β€” (Keyword: tracepolls) β€” tells fetchmail to put poll trace information in the form polling account %s and folder %s into the Received line it generates, where the %s parts get 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's being received from. The folder information is written only since version 6.3.4, so if you're on something ancient that's on you. πŸ“¬
  • --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 info lives 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's 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 a 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. Yes, actually overrides. The cert is the main character here. πŸ‘‘

  • --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).
  • --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. No vibes-based trust here, bestie β€” it's verify or vanish. βœ‹
  • --nosslcertck β€” (Keyword: no sslcertck, only in v6.4.X) β€” the opposite of --sslcertck, and 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. 😭 Yes, every single time.

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

Note that flipping this on will suppress adding the default SSL trusted CA certificates directory β€” unless you set the environment variable FETCHMAIL_INCLUDE_DEFAULT_X509_CA_CERTS to something non-empty. πŸ’… (Like, actually set it. Empty string doesn't count, bestie.)

  • --sslcommonname <common name> β€” (Keyword: sslcommonname; since v6.3.9) Okay so using this is discouraged, fr fr. Before you even touch it, go message the admin of your upstream server and ask them for a proper SSL certificate. If that's literally not happening, then this option can specify the name (CommonName) that fetchmail expects on the server certificate. A correctly configured server has this set to the host name you reach it by, and by default fetchmail expects exactly that. Use this option when the CommonName is set to some other value, to dodge the "Server CommonName mismatch" warning β€” and only if the upstream server's operator can't be made to use proper certificates. Periodt. πŸ‘‘
  • --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 exact format fetchmail uses to report the fingerprint when an SSL connection is established. When you specify it, fetchmail compares the server key fingerprint against the given one, and ✨ the connection fails if they don't match ✨ β€” regardless of the sslcertck setting. The connection also fails if fetchmail can't get an SSL certificate from the server at all. This is how you block man-in-the-middle attacks, but you must get or verify that fingerprint over a secure channel β€” and definitely not over the same Internet connection fetchmail would use. 😭

The fingerprint can be prefixed with an EVP_MD digest algorithm name in curly braces, for instance {MD5}00:01:...:0F. Every digest algorithm your SSL provider library supports can be used. Pick a sensible one β€” like, SHA256, bestie. If the {algo} prefix is omitted, MD5 is used for compatibility with fetchmail 6.4 and older. 🫢

Using this option prevents 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 grab 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, and the first one that's up becomes the forwarding target for the current run. If you don't specify this option, 'localhost' is the default. Each host name may have a port number following it: the port number is separated from the host name by a slash, and the default port is "smtp". If you specify an absolute path name (starting with a /), it gets interpreted as the name of a UNIX socket accepting LMTP connections β€” like the Cyrus IMAP daemon supports. πŸ¦‹

Example:

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

This option can be used with ODMR, and it makes fetchmail a relay between the ODMR server and an 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 uses the default port numbers described below.
  • One of:
    • /notls β€” disables opportunistic STARTTLS even if the server offers it. 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 the server offers it, 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 trying 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

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 a STARTTLS command and upgrade to TLS v1.3, and expect the server's X.509 certificate to match the name commonname.example.com. 🌈

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 out of 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 a loopback interface or a 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 a loopback interface or a 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 isn't 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, instead of forwarding 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 β€” that nonzero status is what tells fetchmail delivery failed and stops the message from being deleted on the server. Do not skip this, bestie. 🚨

If fetchmail is running as root, it sets its user id while delivering mail through an MDA like this: first it peeks at the FETCHMAILUSER, LOGNAME, and USER environment variables β€” in that exact order, bestie. πŸ‘€ The value of the first one on that list that's actually defined (even if it's empty!) gets looked up in the system user database. If literally none of them are defined, fetchmail just rolls with the real user id it was started with. But if one of them was defined and the user it names isn't found? fetchmail stays running as root and does not go check the rest of the list. πŸ™ˆ

So practically speaking: if you're running fetchmail as root (which, again, not recommended), it's most useful to define the FETCHMAILUSER environment variable to set whichever user the MDA should run as. Some MDAs (hi, maildrop) are literally designed to be setuid root and then setuid to the recipient's user id, so you don't even lose functionality this way, even when running fetchmail as an unprivileged user. Check the MDA's manual for the deets. πŸ“–

Some possible MDAs are /usr/sbin/sendmail -i -f %F -- %T (note: several older or vendor sendmail versions mess up and read -- as an address instead of as the thing that marks the end of the option arguments 😭), plus /usr/bin/deliver and /usr/bin/maildrop -d %T. Local delivery addresses get slotted into the MDA command wherever you put %T, and the mail message's From address goes in wherever you put %F.

Do NOT wrap the %F or %T string in single quotes! For both %T and %F, fetchmail itself wraps the addresses in single quotes ('), after stripping any single quotes they might already contain, and then the MDA command gets handed to the shell. She's got it covered, bestie. πŸ’…
Do NOT use an MDA invocation that dispatches on the contents of To/Cc/Bcc, like sendmail -i -t or qmail-inject β€” that's giving mail loops and it will bring the just wrath of many postmasters down upon your head. πŸ’€ This is one of the most frequent configuration errors, fr fr.

Also, do not try to combine multidrop mode with an MDA like 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. Do that and you will lose mail. 😭

The well-known procmail(1) package is very hard to configure properly, ngl. It has a genuinely nasty "fall through to the next rule" behavior on delivery errors (even temporary ones β€” like 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 lots of users find the filter syntax maildrop uses easier to understand too.

Finally, we strongly advise you do not use qmail-inject. Its command line interface is non-standard without giving any 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. 🚩

✨ OPTIONS (still going, we're so back) ✨

  • --lmtp (Keyword: lmtp) β€” Cause delivery via LMTP (Local Mail Transfer Protocol). If you pick this option, a service host and port must be explicitly specified on each host in the smtphost hunt list (see above); 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. 😬

Note that 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. πŸŽ€

🌸 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 (and then it'll 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. ⚑
  • -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's 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 πŸ”

  • -u <name> | --user <name> | --username <name> β€” (Keyword: user[name]) This picks the user identification fetchmail uses when it logs in to the mail server. Bestie, heads up: the right user ID depends on both the server and you β€” it's not a one-size thing. The default is your login name on the client machine that is running fetchmail. Fr fr, go read USER AUTHENTICATION below for the whole story. πŸ’…
  • -I <specification> | --interface <specification> β€” (Keyword: interface) This one says: don't poll unless a specific interface device is up and has a specific local or remote IPv4 address (or a whole range), before polling. (IPv6 is not supported by this option yet, sorry bestie 😭.)

Okay so why does this exist? A lot of the time, fetchmail is used over a transient point-to-point TCP/IP link that's set up directly to a mail server via SLIP or PPP. That channel? Relatively secure. 🫢 But when other TCP/IP routes to the mail server exist (like when the link is connected to an alternate ISP), your username and password can be vulnerable to snooping β€” especially when daemon mode automatically polls for mail, shipping a clear password over the net at predictable intervals πŸ’€. The --interface option is here to prevent exactly that. When the specified link is not 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 β€” and 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) Picture this: daemon mode can cause transient links that are supposed to be automatically taken down after a period of inactivity (looking at you, PPP links) to just... stay 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.

Note that this option may be removed from a future fetchmail version. πŸ‘€
  • --auth <type> β€” (Keyword: auth[enticate]) This option permits you to specify an authentication type (see USER AUTHENTICATION below for details). 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) and 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. 😭

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 πŸŽ€

  • -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. No sloppy perms, 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. ✨
  • --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 only, bestie, not for us πŸ’…

Removed Options πŸͺ¦

  • -T, --netsec β€” gone before version 6.3.0. The inet6_apps library it needed got discontinued, so it's just… not available anymore. RIP to a real one 😭

USER AUTHENTICATION AND ENCRYPTION πŸ”βœ¨

Every mode except ETRN needs the client to authenticate to the server, periodt. Normal user auth in fetchmail is very much giving ftp(1) energy β€” the actual user-id and password you need depend on whatever security system your mail server is running underneath.

So if the mail server is a Unix box and you've got a regular user account on it, you just use your normal login name and password with fetchmail. And here's the cute part: if your login name is the same on the server and the client machine, you literally don't have to specify anything with the -u option β€” the default behavior is to take your login name on the client machine and use it as the user-id on the server machine 🫢. If your login name is different server-side, then you pass that one with -u. Like, say your login name is jsmith on a machine named mailgrunt β€” you'd start fetchmail like this:

fetchmail -u jsmith mailgrunt

By default, fetchmail will prompt you for your mail server password before the connection is even established. This is the safest way to run it, no cap, and it keeps your password from getting compromised πŸ’–. You can also just put your password in your ~/.fetchmailrc file β€” convenient when you're running fetchmail in daemon mode or inside scripts.

Using netrc files πŸ“

If you don't specify a password, and fetchmail can't pull one out of your ~/.fetchmailrc, it goes looking for a ~/.netrc file in your home directory before it ever asks you interactively. And if there's an entry in there matching the mail server, it uses that password ✨. Fetchmail checks for a match on poll name first, and if it finds none, it checks for a match on via name. Real-world example, a .netrc might look like:

machine hermes.example.org
login joe
password topsecret

You can repeat that whole block with different user info if you need more than one password. This feature can save you from duplicating password info across multiple files, which is lowkey iconic.

The netrc file holds login info that was originally set up for ftp(1), but fetchmail understands the typical constructs of that file so it can use it for passwords. The syntax is tokens, usually in pairs with strings. Strings can be quoted with single or double quotes β€” like "quoted string" β€” so you can enclose blanks, and a backslash (\) inside a quoted string escapes the next character, which means a password can actually contain quote marks itself. Wild. Tokens get separated by spaces, tabs or newline characters.

These are the tokens fetchmail understands:

  • machine name β€” identifies a remote computer name that the following tokens apply to. It has to match either fetchmail's poll or via name.
  • login name β€” defines the user name fetchmail matches when hunting for entries. Fetchmail ignores zero-length names or entries without a login.
  • password string β€” defines the password fetchmail will use when machine and login match the poll/via name and the username.
  • default β€” this is like machine, but it'll match any name. Fetchmail ignores it. After this, no more machine sections are permitted.
  • account string β€” fetchmail ignores this token/string pair entirely.
  • macdef macro_name β€” fetchmail ignores this macro definition, meaning this token, the rest of the line, and all following lines until a blank line shows up (i.e., two consecutive new-line characters). Then .netrc parsing resumes.

On mail servers that don't hand out ordinary user accounts, your user-id and password are usually assigned by the server admin when you apply for a mailbox. If you don't know the correct user-id and password for your mailbox account, contact your server administrator πŸ“¬.

Secure Socket Layers (SSL) and Transport Layer Security (TLS) πŸ¦‹

Every retrieval protocol can use SSL or TLS wrapping for the transport. And on top of that, POP3 and IMAP retrieval can also negotiate SSL/TLS by means of STARTTLS (or STLS).

You can reach TLS-encrypted services by specifying the options starting with --ssl, like --ssl, --sslproto, --nosslcertck, and friends. You can also do this through the corresponding user options in the .fetchmailrc file. Some services, like POP3 and IMAP, have different well-known ports defined for the SSL-encrypted versions β€” and those encrypted ports get 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 isn't configured, fetchmail will usually still try to use STARTTLS. In practice, TLS or SSL is still mandatory, because --sslcertck is a default setting and it implicitly requires STARTTLS.

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 you connect to an SSL or TLS encrypted server, the server presents a certificate to the client for validation. The certificate gets 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 say it's currently valid. If any of those checks fail, a warning message gets printed, but the connection continues. The server certificate doesn't 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 has to assume there's a man-in-the-middle attack happening in that scenario, and therefore 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 might request a client side certificate. You can specify a client side public SSL certificate and a private SSL key. If the server requests it, the client certificate gets 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 it 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 whatever the underlying SSL libraries require (OpenSSL in the general case).

⚠️ A word of care about the use of SSL: while the setup mentioned above 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 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). If you care seriously about the security of your mailbox and passwords, strict certificate checking with a certification authority recognized by both server and client β€” or perhaps an SSH tunnel (see below for some examples) β€” is preferable πŸ’€

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, using 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 πŸ™ˆ.

RFC1460 introduced APOP authentication. In this POP3 variant, 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. Every 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.

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's optional, and therefore not implemented by all servers, and some are known to implement it improperly 😭. On many servers, though, the RETR command β€” which retrieves the full message with header and body β€” sets the "seen" flag (in a web interface, for instance), whereas the TOP command doesn't 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 πŸ’….

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 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 🌈

okay so if your fetchmail was compiled with Kerberos support 😌 and you ask for Kerberos auth β€” either via --auth or the .fetchmailrc option authenticate kerberos_v4 β€” then it will go grab a Kerberos ticket from the mail server at the start of every single query. every time. devoted. πŸ’–

pro tip incoming: if either the pollname or the via name is 'hesiod', fetchmail will try to use Hesiod to look up the mail server. cute of it tbh.

If you're doing POP3 or IMAP with GSSAPI authentication, fetchmail expects the server to have RFC1731- or RFC1734-conforming GSSAPI capability, and bestie it will use it. ngl, currently this has only been tested over Kerberos 5, so you're expected to already be holding a ticket-granting ticket. 🎟️ You can pass a username that's different from your principal name using the standard --user command or the .fetchmailrc option user. slay.

If your IMAP daemon returns the PREAUTH response in its greeting line, fetchmail will notice and skip the normal authentication step entirely β€” no password, no nothing, it just walks in. this is lowkey useful, e.g. if you start imapd explicitly using ssh. In that case you can declare the authentication value 'implicit' on that site entry so .fetchmail stops 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, again fetchmail notices and uses 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 β€” iconic, honestly. πŸ”₯

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, whenever it detects "@compuserve.com" in the host name. ✨

If you're using IMAP, Microsoft's NTLM authentication (the one Microsoft Exchange uses) 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 @ gets passed as the username, and the part to the right as the NTLM domain. iykyk. πŸ’…

ESMTP AUTH

fetchmail also supports authentication to the ESMTP server on the client side, per RFC 4952. πŸŽ€

The supported authentication mechanisms are CRAM-MD5, PLAIN, and β€” in fetchmail 6.5.X β€” the obsolete LOGIN.

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. easy. πŸ¦‹


😴 DAEMON MODE 😴

Introducing the daemon mode

In daemon mode, fetchmail puts itself into the background and runs forever β€” querying each specified host, then sleeping for a given polling interval. literally the main character who never leaves the function. πŸ‘‘

Starting the daemon mode

There are several ways to make fetchmail work in daemon mode. On the command line, the --daemon <interval> or -d <interval> option runs fetchmail in daemon mode. You must specify a numeric argument, and that number is a polling interval β€” defined as the time to wait after completing a whole poll cycle with the last server and before starting the next poll cycle with the first server β€” measured 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. and by "a bit less often" I mean exactly: 15 minutes + the time that the poll takes. the math is mathing. 😭

It's 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're not polling the same server with two processes at the same time. the way that two daemons on one mailbox is giving chaos. πŸ’€

Awakening the background daemon

Normally, calling fetchmail while a daemon is 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 β€” those indicate that connections have gotten wedged due to failed authentication or multiple timeouts. so it's a lil reset button. 🫢

Terminating the background daemon

The option -q or --quit will kill a running daemon process instead of waking it up. (If there's no such process, fetchmail will notify you β€” it's not gonna let you yell into the void silently.) πŸ—£οΈ

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. order matters, bestie. πŸ’…

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 lets you 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. πŸ›

Note that 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, 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 doesn't arise there.) πŸ’–

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, or if you break the ~/.fetchmailrc file's syntax, the new instance will softly and silently vanish away on startup. πŸ’€ literally ghosting you. no note, no nothing.

πŸ’… 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's also used as the 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. sneaky. iconic. both.
  • 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 bestie, listen, the actual protocols fetchmail uses to chat with mail servers? lowkey bulletproof. In normal operation, forwarding to port 25, no message is ever deleted (or even marked for deletion) on the host until the SMTP listener on the client side has acknowledged back to fetchmail that the message was either accepted for delivery or rejected due to a spam block. Like, it does not ghost your mail. Ever. 🫢

When you're forwarding to an MDA though? there is more possibility of error. Some MDAs are 'safe' and reliably return a nonzero status on any delivery error, even one caused by temporary resource limits. maildrop(1) is one of those; so are most programs designed as mail transport agents, like sendmail(1), including the sendmail wrapper of Postfix and exim(1). These queens 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. And if that happens… you will lose mail. not a vibe. 😭

The normal mode of fetchmail is to try to download only 'new' messages, leaving untouched (and undeleted) the messages you've 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. girl. why. 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. ancient behaviour, honestly.
  • 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, and wow, rude). 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. upgrade era.
  • 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. πŸ¦‹


πŸ›‘ 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. everyone's doing their own thing, chaos.

  • 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]."). the canon answer, the icon.
  • 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 circumstances 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). three strikes and mail is OUT.

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. saving your bandwidth, slay. πŸ’…

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. it'll be back, king.
  • 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. cold shoulder behaviour, honestly. πŸ’€

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. command line stays the main character, periodt.

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). lock your file DOWN bestie, we are not leaking passwords in the group chat.

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 (\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, and \xhh for hex) to embed non-printable characters or string delimiters in strings. 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. tiny detail, huge consequences.

Warning, bestie: 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). do not assume. they are different fonts of escape sequence.

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. this is THE classic mistake. every time. 😭

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. aesthetic filler words, they ate.

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.) skip = the "leave me on read" option. love that for you. πŸŽ€


πŸ”‘ 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 real quick β€” the Opt column is your short-flag shortcut, and the Mode column (where it exists) is a little mode tag, mostly just m. Don't overthink it, just don't lose it. πŸ’…

  • set daemon, -d β€” sets a background poll interval, in seconds. πŸ‘‘
  • set postmaster β€” gives the name of the last-resort mail recipient. Default is the user running fetchmail, or postmaster if it's being run by root. 🌸
  • set bouncemail β€” sends error mail straight to the sender. (this is the default, bestie) ✨
  • set no bouncemail β€” sends error mail to the local postmaster instead, exactly as per that postmaster global option up above. πŸ’Œ
  • set no spambounce β€” doesn't bounce spam-blocked mail. (default, love that for us) πŸŽ€
  • set spambounce β€” bounces the spam-blocked mail (per the antispam user option) back to the destination, as pointed at by the bouncemail global option.
⚠️ Warning: do not use this to bounce spam back to the sender. Most spam goes out with a fake sender address, so doing this literally hurts innocent bystanders. We do not do that. πŸ™ˆ
  • set no softbounce β€” permanently deletes undeliverable mail. Recommended only if your configuration has been thoroughly tested, fr fr. πŸ’€
  • set softbounce β€” keeps permanently undeliverable mail around as though a temporary error had happened. (default) 🫢
  • set logfile, -L β€” name of a file to append error and status messages to. It's only effective in daemon mode and if fetchmail detaches. When it is effective, it overrides set syslog. πŸ“
  • set pidfile, -p β€” name of the PID file. 🐣
  • set idfile, -i β€” name of the file where UID lists get stored. πŸ—‚οΈ
  • set syslog β€” does error logging through syslog(3). Can get overridden by set logfile. ✨
  • set no syslog β€” turns off error logging through syslog(3). (default) πŸ’€
  • set properties β€” a string value that fetchmail ignores completely (extension scripts are allowed to use it though). 🌈

  • via β€” specify the DNS name of the mail server, overriding the poll name. πŸ’–
  • proto[col], -p β€” specify the protocol (case insensitive, slay): POP2, POP3, IMAP, APOP, KPOP. πŸ”₯
  • local[domains] (mode m) β€” specify the domain(s) to be regarded as local. 🏠
  • port β€” specify the TCP/IP service port. (obsolete, bestie β€” use service instead) πŸ™ˆ
  • service, -P β€” specify the service name. A numeric value is also allowed and it gets treated as a TCP/IP port number. πŸ”’
  • auth[enticate] β€” set the authentication type. (default any) πŸ”
  • timeout, -t β€” server inactivity timeout, in seconds. (default 300) ⏳
  • envelope, -E (mode m) β€” specify the envelope-address header name. βœ‰οΈ
  • no envelope (mode m) β€” stop looking for the envelope address. 🚫
  • qvirtual, -Q (mode m) β€” Qmail virtual domain prefix to strip off the user name. 🧚
  • aka (mode m) β€” specify alternate DNS names of the mail server. πŸ‘―
  • interface, -I β€” specify the IP interface(s) that must be up for a server poll to actually take place. πŸ›°οΈ
  • monitor, -M β€” specify an 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 (mode m) β€” enable DNS lookup for multidrop. (default) 🌐
  • no dns (mode m) β€” disable DNS lookup for multidrop. 🚫
  • checkalias (mode m) β€” do the comparison by IP address for multidrop. πŸ”
  • no checkalias (mode m) β€” do the comparison by name for multidrop. (default) 🏷️
  • uidl, -U β€” force POP3 to use client-side UIDLs. (recommended, no cap) βœ…
  • no uidl β€” turn off POP3's 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, iykyk) 🎫
  • 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. Peep --idle. πŸ’€

  • user[name], -u β€” this is the user description, and it must come first β€” after the server description and after any possible server options, and before any user options. The way it has to be in order is literally so serious. πŸ‘‘

so finishing off that last entry, bestie: it sets the remote user name if it's by itself or followed by there, or the local user name if it's followed by here. πŸ’…

  • is β€” connects local and remote user names.
  • to β€” connects local and remote user names.
  • pass, password β€” specify the remote account password. πŸ”‘
  • ssl β€” connect to the server over the base protocol you specified, but using SSL encryption.
  • sslcert β€” specify the file for the client-side public SSL certificate.
  • sslcertck β€” enable strict certificate checking and abort the connection on failure. It's only been the default since fetchmail v6.4.0, no cap.
  • no sslcertck β€” disable strict certificate checking and let connections keep going even when verification fails. Lowkey discouraged 🚩 should only be used together with sslfingerprint.
  • sslcertfile β€” specify the file with trusted CA certificates.
  • sslcertpath β€” specify a 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 fingerprint from an MD5 hash. Fetchmail will disconnect and log an error if it doesn't match. 😭
  • sslkey β€” specify the file for the client-side private SSL key.
  • sslproto β€” force the ssl protocol for the connection.
  • folder, -r β€” specify the 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 get interpreted as spam-policy blocks.
  • mda, -m β€” specify the MDA for local delivery.
  • bsmtp β€” specify the BSMTP batch file to append to.
  • preconnect β€” command to be executed before each connection. πŸƒ
  • postconnect β€” command to be executed after each connection.
  • keep, -k β€” don't delete seen messages from the 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 they've been seen or not.
  • rewrite β€” rewrite destination addresses for reply (this is the default).
  • stripcr β€” strip carriage returns from the ends of lines.
  • forcecr β€” force carriage returns at the ends of lines.
  • pass8bits β€” force BODY=8BITMIME to the ESMTP listener.
  • 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 the server (default).
  • no flush β€” don't flush all seen messages before querying (default).
  • no fetchall β€” retrieve only new messages (default).
  • no rewrite β€” don't rewrite headers.
  • no stripcr β€” don't strip carriage returns (default).
  • no forcecr β€” don't force carriage returns at EOL (default).
  • no pass8bits β€” don't force BODY=8BITMIME to the ESMTP listener (default).
  • no dropstatus β€” don't drop Status headers (default).
  • no dropdelivered β€” don't drop Delivered-To headers (default).
  • no mimedecode β€” don't convert quoted-printable to 8-bit in MIME messages (default).
  • no idle β€” don't idle waiting for new messages after each poll (IMAP only).
  • limit, -l β€” set the message size limit.
  • warnings, -w β€” set the message size warning interval.
  • batchlimit, -b β€” max number of messages to forward in a single connect.
  • fetchlimit, -B β€” max number of messages to fetch in a single connect.
  • fetchsizelimit β€” max number of message sizes to fetch in a single transaction.
  • fastuidl β€” use binary search for the first unseen message (POP3 only).
  • expunge, -e β€” perform an expunge on every #th message (IMAP and POP3 only).
  • properties β€” the string value is ignored by fetchmail (may be used by extension scripts).

All user options must begin with a user description (that's the user or username option) and they follow all the server descriptions and options. Order is everything, bestie. ✨

In the .fetchmailrc file, that envelope string argument can be preceded by a whitespace-separated number. If you do give that number, it's the number of such headers to skip over (so an argument of 1 selects the second header of the given type). Sometimes this is genuinely 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 the 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.

The via option is for when you want more than one configuration pointing at the same site. If it's there, the string argument gets taken as the actual DNS name of the mail server host to query. That overrides the argument of poll, which can then simply be a distinct label for the configuration (like, what you'd give on the command line to explicitly query this host). πŸ¦‹

The interval option (which takes a numeric argument) lets you 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.

Singledrop versus Multidrop options πŸ’Œ

Please, please make sure you read the section titled THE USE AND ABUSE OF MULTIDROP MAILBOXES if you're planning to use multidrop mode. Fr fr, it matters.

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. Heads up though: 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. πŸ‘‘

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's 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. Periodt.

When there's 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 gets bounced to the sender, but if the bouncemail global option is off, the mail goes to the local postmaster instead (see the postmaster global option). See also BUGS. 😭


  • dns β€” normally on, bestie, and it's the vibe check for how addresses out of multidrop mailboxes get verified. When it's on, fetchmail runs its little logic on every host address that doesn't match an aka or localdomains declaration, and looks it up via DNS. And if a mail server username shows up attached to a matching host name part? Its local mapping gets added to the list of local recipients. πŸ’…
  • checkalias β€” normally off, and it's giving "extra credit for the dns keyword." It stretches out those multidrop-mode lookups so you can vibe with remote MTAs that introduce themselves using their canonical name while you're actually polling them through an alias. When that happens, the checks to pull out the envelope address flop 😭, and fetchmail reverts to delivery using the To/Cc/Bcc headers (peep Header versus Envelope addresses, below). Turning this on tells fetchmail to grab all the IP addresses tied to both the poll name and the name the remote MTA is using, then compare those IPs. Iconic when the remote server keeps changing its canonical name constantly β€” otherwise you'd be stuck editing your rcfile every five minutes. 🫠 Heads up though: checkalias does nothing if no dns is in the rcfile. Zero. Nada. πŸ’€
  • aka β€” multidrop mailbox realness. It lets you pre-declare a whole list of DNS aliases for a server. It's an optimization hack, no cap β€” trading space for speed. While fetchmail is groveling through message headers hunting for mail server names, having the common ones already declared saves it a bunch of DNS lookups. ⚑ Note: the names you pass as arguments to aka are matched as suffixes β€” so if you write aka netaxs.com, it matches not just the host name netaxs.com but any host name ending in .netaxs.com, like pop3.netaxs.com and mail.netaxs.com. Slay. πŸŽ€
  • localdomains β€” lets you declare a list of domains fetchmail should treat as local. When fetchmail is parsing address lines in multidrop modes and a trailing chunk of a host name matches a declared local domain, that address gets passed straight through to the listener or MDA unaltered (local-name mappings do not get applied). ✨
  • no envelope β€” if you're using localdomains, you might also need this. It shuts off fetchmail's normal attempt to deduce an envelope address from the Received line or X-Envelope-To header or whatever header was previously set by envelope. And if you set no envelope in the defaults entry, you can totally undo it in individual entries with envelope <string>. Special case alert 🚨: envelope "Received" restores the default parsing of Received lines.
  • password β€” needs a string argument, and that string is the password used with the entry's server. πŸ”
  • preconnect β€” lets you specify a shell command that runs just before each time fetchmail establishes a mail server connection. Super handy if you're trying to set up secure POP connections with the help of ssh(1). If the command returns a nonzero status, the poll of that mail server gets aborted. πŸ›‘
  • postconnect β€” same energy, opposite timing: a shell command that runs just after each time a mail server connection is taken down. πŸ¦‹
  • forcecr β€” controls whether lines terminated by LF only get CRLF termination before forwarding. Strictly speaking, RFC821 requires this, but honestly few MTAs enforce it, so this option is normally off. (Only one such MTA β€” qmail β€” was in significant use at the time of writing.) πŸ™ˆ
  • stripcr β€” controls whether carriage returns get stripped out of retrieved mail before it's forwarded. Usually you don't need to touch this, because it defaults to on (CR stripping enabled) when there's an MDA declared, but off (CR stripping disabled) when forwarding is via SMTP. And if stripcr and forcecr are both on, <hotpink>stripcr wins β€” it overrides. πŸ‘‘
  • pass8bits β€” exists to deal with Microsoft mail programs that stupidly slap a Content-Transfer-Encoding: 7bit on literally everything πŸ™„. With this off (the default) and such a header present, fetchmail declares BODY=7BIT to an ESMTP-capable listener; that causes problems for messages actually using 8-bit ISO or KOI-8 character sets, which 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. πŸ’œ
  • dropstatus β€” controls whether nonempty Status and X-Mozilla-Status lines are retained in fetched mail (the default) or discarded. Keeping them lets your MUA see which messages (if any) were marked seen on the server. On the other hand, it can confuse some new-mail notifiers, which assume anything with a Status line in it has already been seen. (Note: the empty Status lines inserted by some buggy POP servers are unconditionally discarded, periodt.) πŸ“
  • dropdelivered β€” controls whether Delivered-To headers get kept in fetched mail (the default) or discarded. These headers are added by qmail and Postfix mail servers 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. ⚠️
  • mimedecode β€” controls whether MIME messages using the quoted-printable encoding get automatically converted into pure 8-bit data. If you're delivering mail to an ESMTP-capable, 8-bit-clean listener (that includes all the major MTAs like sendmail), this automatically converts quoted-printable message headers and data into 8-bit data, making it way easier to understand when you're reading mail. If your e-mail programs already know how to deal with MIME messages, you don't need this at all. It's 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. πŸ’€
  • idle β€” meant for IMAP servers supporting the RFC2177 IDLE command extension, but it doesn't strictly require it. If it's enabled and fetchmail detects that IDLE is supported, an IDLE gets issued at the end of each poll. That tells the IMAP server to hold the connection open and notify the client when new mail is available. If IDLE isn't supported, fetchmail simulates it by periodically issuing NOOP. If you need to poll a link frequently, IDLE saves 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'll 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. πŸ™ƒ
  • properties β€” this one's an extension mechanism. It takes a string argument, which fetchmail itself just ignores. The string argument may be used to store configuration information for scripts that require it. In particular, the output of the --configdump option makes properties associated with a user entry readily available to a Python script. 🐍✨

πŸŽ€ Miscellaneous Run Control Options πŸŽ€

The words here and there have genuinely useful English-like significance, bestie. Normally user eric is esr means that mail for the remote user eric is to be delivered to esr β€” but you can make that so much clearer by saying user eric there is esr here, or flip it around with user esr here is eric there. Readability who? We love her. πŸ’–


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. Those defaults may be overridden by later options. πŸ’…

There are some global option statements, too: 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 just like --daemon does. That 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. And finally, set syslog sends log messages to syslogd(8). 🫢

πŸ› DEBUGGING FETCHMAIL πŸ›

So your fetchmail is acting up bestie 😭 and you need to figure out why. Say less, let's go.

πŸ’€ Fetchmail crashing πŸ’€

There are various ways in that fetchmail may "crash", i. e. stop operation suddenly and unexpectedly. A "crash" usually refers to an error condition that the software did not handle by itself. A well-known failure mode is the "segmentation fault" or "signal 11" or "SIGSEGV" or just "segfault" for short.

These can be caused by hardware or by software problems. Here's how to tell them apart, periodt:

  • Software-induced segfaults can usually be reproduced easily and in the same place.
  • Hardware-induced segfaults can 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 same way.

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

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

πŸŽ€ Enabling fetchmail core dumps πŸŽ€

By default, fetchmail suppresses core dumps as these might contain passwords and other sensitive information 😳 (yeah, your secrets could be sitting in there, no cap). For debugging fetchmail crashes, obtaining a "stack backtrace" from a core dump is often the quickest way to solve the problem, and when posting your problem on a mailing list, the developers may ask you for a "backtrace".

  1. To get useful backtraces, fetchmail needs to be installed without getting stripped of its compilation symbols. Unfortunately, most binary packages that are 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" that can usually be configured with a tool named limit or ulimit. See the documentation for your shell for details. In the popular bash shell, ulimit -Sc unlimited will allow the core dump. πŸ¦‹
  2. 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, 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. πŸ”

πŸ“¬ INTERACTION WITH RFC 822 πŸ“¬

When trying to determine the originating address of a message, fetchmail looks through headers in the following 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 less annoying). πŸ’…

In multidrop mode, destination headers are processed as follows: 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 🌈

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. πŸ”

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! 😭

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 πŸ’–

okay bestie, listen. Use the multiple-local-recipients feature with caution β€” it can bite. 🫠

All multidrop features are ineffective in ETRN and ODMR modes. Like, all of them. Every single one. Not applicable, periodt.

Also, note that in multidrop mode duplicate mails may be suppressed. A piece of mail is considered duplicate if it does not have a discernible envelope recipient address, has the same header as the message immediately preceding, and more than one addressee. Such runs of messages may be generated when copies of a message addressed to multiple users are delivered to a multidrop box. (To be precise, fetchmail 6.2.5 through 6.4.X use an MD5 hash of the raw message header, and only fetchmail 6.4.16+ 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.) 🧚 the lore goes deep.

Note that this duplication killer code checking the entire header is very restrictive and may not suppress many duplicates in practice β€” for instance, if some X-Original-To or Delivered-To header differs. This is intentional and correct in such situations: wherever envelope information is available, it should be used for reliable delivery of mailing list and blind carbon copy (Bcc) messages. See the subsection Duplicate suppression below for suggestions. πŸ’…

πŸ¦‹ Header versus Envelope addresses πŸ¦‹

The fundamental problem is that by having your mail server toss several peoples' mail in a single maildrop box, you may have thrown away potentially vital information about who each piece of mail was actually addressed to (the 'envelope address', as opposed to the header addresses in the RFC822 To/Cc headers β€” the Bcc is not available at the receiving end). This 'envelope address' is the address you need in order 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, nor if there is more than one recipient. 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. Note that writing an envelope header of this kind 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. 🫣 privacy is not a vibe, protect it.

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 these 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! πŸ‘€ heads up bestie.

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. This is what makes the multidrop feature risky without proper envelope information. 😭 losing mail is not the moment.

A related problem is that when you blind-copy a mail message, the Bcc information is carried only as envelope address (it is removed from the headers by the sending mail server, so fetchmail can see it only if there is an X-Envelope-To header). Thus, 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.

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, however. You will begin to see this when a message comes in that is 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. like. at all 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. πŸ‘» no cap.

πŸŽ€ 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 is 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. 🏎️ fast girl energy.

🧚 Duplicate suppression on multidrop 🧚

If fetchmail's duplicate suppression code does not kick in for your multidrop mail account, other options is 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

go off bestie, direct connection, no middleman. πŸ¦‹

✨ EXIT CODES ✨

okay bestie listen up, because this is the part where fetchmail tells you what happened in numbers πŸ’… helping you use fetchmail in shell scripts, an exit status code gets returned to give an indication of what occurred during a given connection.

here's the whole lineup of exit codes fetchmail hands back:

  • 0 β€” one or more messages were successfully retrieved (or, if the -c option was selected, they were found waiting but not retrieved). slay, we ate. πŸ‘‘
  • 1 β€” there was no mail awaiting retrieval. (there may have been old mail still sitting on the server but it wasn't selected for retrieval.) if you do NOT want "no mail" to be an error condition (like, say, for cron jobs), use a POSIX-compliant shell and add
|| [ $? -eq 1 ]

to the end of the fetchmail command line. note that this leaves 0 untouched, maps 1 to 0, and maps all other codes to 1. also see item #C8 in the FAQ πŸ’–

  • 2 β€” an error was encountered when attempting to open a socket to retrieve mail. if you don't know what a socket is, don't worry about it β€” just treat this as an 'unrecoverable error'. this error can also fire because a protocol fetchmail wants to use is not listed in /etc/services.
  • 3 β€” the user authentication step failed. usually this means a bad user-id, password, or APOP id was specified. or it may mean you tried to run fetchmail under circumstances where it did not have standard input attached to a terminal and could not prompt for a missing password. πŸ™ˆ
  • 4 β€” some sort of fatal protocol error was detected. πŸ’€
  • 5 β€” there was a syntax error in the arguments to fetchmail, or a pre- or post-connect command failed.
  • 6 β€” the run control file had bad permissions.
  • 7 β€” there was an error condition reported by the server. can also fire if fetchmail timed out while waiting for the server.
  • 8 β€” client-side exclusion error. this means fetchmail either found another copy of itself already running, or failed in such a way that it's not sure whether another copy is running.
  • 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" will be returned instead, see above. may be returned when talking to qpopper or other servers that can respond with "lock busy" or some similar text containing the word "lock".
  • 10 β€” the fetchmail run failed while trying to do an SMTP port open or transaction.
  • 11 β€” fatal DNS error. fetchmail encountered an error while performing a DNS lookup at startup and could not proceed.
  • 12 β€” BSMTP batch file could not be opened.
  • 13 β€” poll terminated by a fetch limit (see the --fetchlimit option).
  • 14 β€” server busy indication.
  • 23 β€” internal error. you should see a message on standard error with details.
  • 24 - 26, 28, 29 β€” these are internal codes and should not appear externally.

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 β€” default run control file (location can be overridden with environment variables). this is THE one, the main character file πŸŽ€
  • ~/.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) to help 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 providing it with environment variables. some may alter the operation of libraries that fetchmail links against, for instance, OpenSSL. note that in daemon mode, you'll need to quit the background daemon process and start a new fetchmail daemon for environment changes to take effect. no cap, just restart the whole vibe. πŸ¦‹

  • FETCHMAILHOME β€” if this environment variable is set to a valid and existing directory name, fetchmail will read $FETCHMAILHOME/fetchmailrc (the dot is missing in this case), $FETCHMAILHOME/.fetchids (keeping its dot) and $FETCHMAILHOME/fetchmail.pid (without dot) rather than from the user's home directory. the .netrc file is always looked for in the invoking user's home directory (or $HOME_ETC) regardless of FETCHMAILHOME's setting. iykyk πŸ’…
  • FETCHMAILUSER β€” if this environment variable is set, it is used as the name of the calling user (default local name) for purposes such as mailing error notifications. otherwise, if either the LOGNAME or USER variable is correctly set (e.g., the corresponding UID matches the session user ID) then that name is used as 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).
  • FETCHMAIL_DISABLE_CBC_IV_COUNTERMEASURE β€” (since v6.3.22): if this environment variable 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 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 environment variable 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 does not work properly.
  • FETCHMAIL_INCLUDE_DEFAULT_X509_CA_CERTS β€” (since v6.3.17): if this environment variable 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. the 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 environment variable is set and not empty, then enable wolfSSL's debug mode. this will emit huge amounts of debug output to stderr. like, so much. brace yourself 😭
  • HOME β€” (documented since 6.4.1): this variable is normally set to the user's home directory. if it is set to a different directory than what is 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 β€” such as 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 SIGHUP due to logout can retain the default action of killing it).

running fetchmail in foreground while a background fetchmail is running will do whichever of these is appropriate to wake it up. iconic behavior, honestly. πŸ’œ

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

okay bestie, sit down, because this is the part where fetchmail is honest about its flaws and honestly? self-awareness is iconic

fr fr though, check the NEWS file that shipped with fetchmail for more known bugs than the ones listed here. yes, there are more. no, we're not hiding them, they're literally right there in the NEWS file πŸ’–


Fetchmail cannot handle user names that contain blanks after a @ character, for instance demonstr@ti on. These are rather uncommon and only hurt when using UID-based --keep setups, so the 6.X.Y versions of fetchmail will not be fixed. not me serving you an unfixable bug with a smile 🫢

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. no duplicate queens allowed πŸ’…

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. lowkey foreshadowing, but okay 😭

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 πŸ’€πŸ’€πŸ’€ (real zombies, not the cute aesthetic kind)

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. it's giving legacy ✨

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. the parser is not beating the "only handles normal things" allegations πŸ™ˆ

In a message with multiple envelope headers, only the last one processed will be visible to fetchmail.

⚠️ SECURITY TEA, PAY ATTENTION BESTIE ⚠️

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. so basically: tunnel it or your password is out here in the wild with no supervision πŸ˜­πŸ”’

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. root + attacker-controlled text = absolutely not the vibe πŸ‘‘πŸš«

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. it's giving "no thoughts, just ✨perished✨" 🌸

The -f - option (reading a configuration from stdin) is incompatible with the plugin option.

The 'principal' option only handles Kerberos IV, not V.

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. 64 chars and beyond? not invited to the party πŸ’…

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, the original says "An fetchmail FAQ". we keep the facts and the grammar exactly as it is, bestie, no editing the lore πŸŽ€)


πŸ‘‘ 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 dream team fr fr 🫢

Most of the code is from Eric S. Raymond. Too many other people to name here have contributed code and patches. y'all are the real ones 🌈

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 of the century honestly πŸ’–

This manual page has been improved by Matthias Andree, R. Hannes Beinert, and Héctor García. iconic behavior ✨


πŸ¦‹ SEE ALSO πŸ¦‹

like a little reading list, do it for the plot πŸ“š


πŸ’œ 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 flex πŸ’…

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 page, bestie πŸŽ€ you read all of it. main character energy, no notes. πŸ’…βœ¨

This was fetchmail 6.6.6, dated 2025-10-10, FETCHMAIL(1) β€” go forth and poll responsibly, and remember: tunnel your passwords, never use %F or %T in an mda from root, and hydrate πŸ’–πŸ¦‹πŸŒΈπŸ‘‘

πŸ“¦ where this page comes from