]> Pileus Git - ~andy/fetchmail/blob - fetchmail.man
Documentation updates.
[~andy/fetchmail] / fetchmail.man
1 '\" t
2 .\" ** The above line should force tbl to be used as a preprocessor **
3 .\"
4 .\" Man page for fetchmail
5 .\"
6 .\" For license terms, see the file COPYING in this directory.
7 .TH fetchmail 1
8 .SH NAME
9 fetchmail \- fetch mail from a POP, IMAP, ETRN, or ODMR-capable server
10
11 .SH SYNOPSIS
12 \fBfetchmail\fR [\fIoption...\fR] [\fImailserver...\fR]
13 .br
14 \fBfetchmailconf\fR
15
16 .SH DESCRIPTION
17 .I fetchmail
18 is a mail-retrieval and forwarding utility; it fetches mail from
19 remote mailservers and forwards it to your local (client) machine's
20 delivery system.  You can then handle the retrieved mail using normal
21 mail user agents such as \fImutt\fR(1), \fIelm\fR(1) or \fIMail\fR(1).
22 The \fIfetchmail\fR utility can be run in a daemon mode to repeatedly
23 poll one or more systems at a specified interval.
24 .PP
25 The
26 .I fetchmail
27 program can gather mail from servers supporting any of the common
28 mail-retrieval protocols: POP2, POP3, IMAP2bis, IMAP4, and IMAPrev1.
29 It can also use the ESMTP ETRN extension and ODMR.  (The RFCs describing all
30 these protocols are listed at the end of this manual page.)
31 .PP
32 While
33 .I fetchmail
34 is primarily intended to be used over on-demand TCP/IP links (such as
35 SLIP or PPP connections), it may also be useful as a message transfer
36 agent for sites which refuse for security reasons to permit
37 (sender-initiated) SMTP transactions with sendmail.
38 .PP
39 As each message is retrieved \fIfetchmail\fR normally delivers it via SMTP to
40 port 25 on the machine it is running on (localhost), just as though it
41 were being passed in over a normal TCP/IP link.  The mail will then be
42 delivered locally via your system's MDA (Mail Delivery Agent, usually
43 \fIsendmail\fR(8) but your system may use a different one such
44 as \fIsmail\fR, \fImmdf\fR, \fIexim\fR, or \fIqmail\fR).  All the
45 delivery-control mechanisms (such as \fI.forward\fR files) normally
46 available through your system MDA and local delivery agents will
47 therefore work automatically.
48 .PP
49 If no port 25 listener is available, but your fetchmail configuration
50 was told about a reliable local MDA, it will use that MDA for local
51 delivery instead.  At build time, fetchmail normally looks for
52 executable
53 .IR procmail (1)
54 and 
55 .IR sendmail (1)
56 binaries.
57 .PP
58 If the program
59 .I fetchmailconf
60 is available, it will assist you in setting up and editing a
61 fetchmailrc configuration.  It runs under X and requires that the
62 language Python and the Tk toolkit be present on your system.  If
63 you are first setting up fetchmail for single-user mode, it is
64 recommended that you use Novice mode.  Expert mode provides
65 complete control of fetchmail configuration, including the
66 multidrop features.  In either case, the `Autoprobe' button
67 will tell you the most capable protocol a given mailserver
68 supports, and warn you of potential problems with that server.
69
70 .SH GENERAL OPERATION
71 The behavior of
72 .I fetchmail
73 is controlled by command-line options and a run control file,
74 .IR ~/.fetchmailrc\fR ,
75 the syntax of which we describe in a later section (this file is what
76 the \fIfetchmailconf\fR program edits).  Command-line options override
77 .I ~/.fetchmailrc
78 declarations.
79 .PP
80 Each server name that you specify following the options on the
81 command line will be queried.  If you don't specify any servers
82 on the command line, each `poll' entry in your 
83 .I ~/.fetchmailrc
84 file will be queried.
85 .PP
86 To facilitate the use of
87 .I fetchmail
88 in scripts and pipelines, it returns an appropriate exit code upon 
89 termination -- see EXIT CODES below.
90 .PP
91 The following options modify the behavior of \fIfetchmail\fR.  It is
92 seldom necessary to specify any of these once you have a
93 working \fI.fetchmailrc\fR file set up.
94 .PP
95 Almost all options have a corresponding keyword which can be used to
96 declare them in a 
97 .I .fetchmailrc
98 file.
99 .PP
100 Some special options are not covered here, but are documented instead
101 in sections on AUTHENTICATION and DAEMON MODE which follow.
102 .SS General Options
103 .TP
104 .B \-V | \-\-version
105 Displays the version information for your copy of 
106 .IR fetchmail .
107 No mail fetch is performed.
108 Instead, for each server specified, all the option information
109 that would be computed if
110 .I fetchmail
111 were connecting to that server is displayed.  Any non-printables in
112 passwords or other string names are shown as backslashed C-like
113 escape sequences.  This option is useful for verifying that your
114 options are set the way you want them.
115 .TP
116 .B \-c | \-\-check
117 Return a status code to indicate whether there is mail waiting,
118 without actually fetching or deleting mail (see EXIT CODES below).
119 This option turns off daemon mode (in which it would be useless).  It
120 doesn't play well with queries to multiple sites, and doesn't work
121 with ETRN or ODMR.  It will return a false positive if you leave read but
122 undeleted mail in your server mailbox and your fetch protocol can't
123 tell kept messages from new ones.  This means it will work with IMAP,
124 not work with POP2, and may occasionally flake out under POP3.
125 .TP
126 .B \-s | \-\-silent
127 Silent mode.  Suppresses all progress/status messages that are
128 normally echoed to standard error during a fetch (but does not
129 suppress actual error messages).  The --verbose option overrides this.
130 .TP
131 .B \-v | \-\-verbose
132 Verbose mode.  All control messages passed between 
133 .I fetchmail
134 and the mailserver are echoed to stdout.  Overrides --silent.
135 Doubling this option (-v -v) causes extra diagnostic information
136 to be printed. 
137 .SS Disposal Options
138 .TP
139 .B \-a | \-\-all
140 (Keyword: fetchall)
141 Retrieve both old (seen) and new messages from the mailserver.  The
142 default is to fetch only messages the server has not marked seen.
143 Under POP3, this option also forces the use of RETR rather than TOP.
144 Note that POP2 retrieval behaves as though --all is always on (see
145 RETRIEVAL FAILURE MODES below) and this option does not work with ETRN
146 or ODMR.
147 .TP
148 .B \-k | \-\-keep
149 (Keyword: keep)
150 Keep retrieved messages on the remote mailserver.  Normally, messages 
151 are deleted from the folder on the mailserver after they have been retrieved.
152 Specifying the 
153 .B keep 
154 option causes retrieved messages to remain in your folder on the
155 mailserver.  This option does not work with ETRN or ODMR.
156 .TP
157 .B \-K | \-\-nokeep
158 (Keyword: nokeep)
159 Delete retrieved messages from the remote mailserver.  This
160 option forces retrieved mail to be deleted.  It may be useful if
161 you have specified a default of \fBkeep\fR in your
162 \&\fI.fetchmailrc\fR.  This option is forced on with ETRN and ODMR.
163 .TP
164 .B \-F | \-\-flush
165 POP3/IMAP only.  Delete old (previously retrieved) messages from the mailserver
166 before retrieving new messages. This option does not work with ETRN or
167 ODMR.  In combination with the --limit option, --flush can be used to 
168 delete oversized messages waiting on the server.
169 Warning: if your local MTA hangs and fetchmail is aborted, the next
170 time you run fetchmail, it will delete mail that was never delivered to you.
171 What you probably want is the default setting: if you don't specify `-k', then
172 fetchmail will automatically delete messages after successful delivery.
173 .SS Protocol and Query Options
174 .TP
175 .B \-p <proto> | \-\-protocol <proto>
176 (Keyword: proto[col])
177 Specify the protocol to use when communicating with the remote 
178 mailserver.  If no protocol is specified, the default is AUTO.
179 .I proto 
180 may be one of the following:
181 .RS
182 .IP AUTO
183 Tries IMAP, POP3, and POP2 (skipping any of these for which support
184 has not been compiled in).
185 .IP POP2
186 Post Office Protocol 2
187 .IP POP3
188 Post Office Protocol 3
189 .IP APOP
190 Use POP3 with old-fashioned MD5-challenge authentication.
191 .IP RPOP
192 Use POP3 with RPOP authentication.
193 .IP KPOP
194 Use POP3 with Kerberos V4 authentication on port 1109.
195 .IP SDPS
196 Use POP3 with Demon Internet's SDPS extensions.
197 .IP IMAP
198 IMAP2bis, IMAP4, or IMAP4rev1 (\fIfetchmail\fR autodetects their capabilities).
199 .IP ETRN
200 Use the ESMTP ETRN option.
201 .IP ODMR
202 Use the the On-Demand Mail Relay ESMTP profile.
203 .RE
204 .P
205 All these alternatives work in basically the same way (communicating
206 with standard server daemons to fetch mail already delivered to a
207 mailbox on the server) except ETRN and ODMR.  The ETRN mode
208 allows you to ask a compliant ESMTP server (such as BSD sendmail at
209 release 8.8.0 or higher) to immediately open a sender-SMTP connection
210 to your client machine and begin forwarding any items addressed to
211 your client machine in the server's queue of undelivered mail.   The
212 ODMR mode requires an ODMR-capable server and works similarly to
213 ETRN, except that it does not require the client machine to have
214 a static DNS.
215 .TP
216 .B \-U | \-\-uidl
217 (Keyword: uidl)
218 Force UIDL use (effective only with POP3).  Force client-side tracking
219 of `newness' of messages (UIDL stands for ``unique ID listing'' and is
220 described in RFC1725).  Use with `keep' to use a mailbox as a baby
221 news drop for a group of users. The fact that seen messages are skipped
222 is logged, unless error logging is done through syslog while running in
223 daemon mode.
224
225 .TP
226 .B \-P <portnumber> | \-\-port <portnumber>
227 (Keyword: port)
228 The port option permits you to specify a TCP/IP port to connect on. 
229 This option will seldom be necessary as all the supported protocols have
230 well-established default port numbers.
231 .TP
232 .B \-\-principal <principal>
233 (Keyword: principal)
234 The principal option permits you to specify a service principal for
235 mutual authentication.  This is applicable to POP3 or IMAP with Kerberos
236 authentication.
237 .TP 
238 .B \-t <seconds> | -\-timeout <seconds>
239 (Keyword: timeout)
240 The timeout option allows you to set a server-nonresponse
241 timeout in seconds.  If a mailserver does not send a greeting message
242 or respond to commands for the given number of seconds,
243 \fIfetchmail\fR will hang up on it.  Without such a timeout
244 \fIfetchmail\fR might hang up indefinitely trying to fetch mail from a
245 down host.  This would be particularly annoying for a \fIfetchmail\fR
246 running in background.  There is a default timeout which fetchmail -V
247 will report.  If a given connection receives too many timeouts in 
248 succession, fetchmail will consider it wedged and stop retrying,
249 the calling user will be notified by email if this happens.
250 .TP
251 .B \-\-plugin <command>
252 (Keyword: plugin) The plugin option allows you to use an external
253 program to establish the TCP connection.  This is useful if you want
254 to use socks, SSL, ssh, or need some special firewalling setup.  The
255 program will be looked up in $PATH and can optionally be passed the
256 hostname and port as arguments using "%h" and "%p" respectively (note
257 that the interpolation logic is rather primitive, and these token must
258 be bounded by whitespace or beginning of string or end of string).
259 Fetchmail will write to the plugin's stdin and read from the plugin's
260 stdout.
261 .TP
262 .B \-\-plugout <command>
263 (Keyword: plugout)
264 Identical to the plugin option above, but this one is used for the SMTP
265 connections (which will probably not need it, so it has been separated
266 from plugin).
267 .TP
268 .B \-r <name> | \-\-folder <name>
269 (Keyword: folder[s])
270 Causes a specified non-default mail folder on the mailserver (or
271 comma-separated list of folders) to be retrieved.  The syntax of the
272 folder name is server-dependent.  This option is not available under
273 POP3, ETRN, or ODMR.
274 .TP
275 .B \-\-tracepolls
276 (Keyword: tracepolls)
277 Tell fetchail to poll trace information in the form `polling %s
278 account %s' to the Received line it generates, where the %s parts are
279 replaced by the user's remote name and the poll label (the Received
280 header also normally includes the server's truename).  This can be
281 used to facilate mail filtering based on the account it is being
282 received from.
283 .TP
284 .B \-\-ssl
285 (Keyword: ssl)
286 Causes the connection to the mail server to be encrypted via SSL.  Connect
287 to the server using the specified base protocol over a connection secured
288 by SSL.  SSL support must be present at the server.  If no port is
289 specified, the connection is attempted to the well known port of the SSL
290 version of the base protocol.  This is generally a different port than the
291 port used by the base protocol.  For IMAP, this is port 143 for the clear
292 protocol and port 993 for the SSL secured protocol.
293 .TP
294 .B \-\-sslcert <name>
295 (Keyword: sslcert)
296 Specifies the file name of the client side public SSL certificate.  Some
297 SSL encrypted servers may require client side keys and certificates for
298 authentication.  In most cases, this is optional.  This specifies
299 the location of the public key certificate to be presented to the server
300 at the time the SSL session is established.  It is not required (but may
301 be provided) if the server does not require it.  Some servers may
302 require it, some servers may request it but not require it, and some
303 servers may not request it at all.  It may be the same file
304 as the private key (combined key and certificate file) but this is not
305 recommended.
306 .TP
307 .B \-\-sslkey <name>
308 (Keyword: sslkey)
309 Specifies the file name of the client side private SSL key.  Some SSL
310 encrypted servers may require client side keys and certificates for
311 authentication.  In most cases, this is optional.  This specifies
312 the location of the private key used to sign transactions with the server
313 at the time the SSL session is established.  It is not required (but may
314 be provided) if the server does not require it.  Some servers may
315 require it, some servers may request it but not require it, and some
316 servers may not request it at all.  It may be the same file
317 as the public key (combined key and certificate file) but this is not
318 recommended.  If a password is required to unlock the key, it will be
319 prompted for at the time just prior to establishing the session to the
320 server.  This can cause some complications in daemon mode.
321 .TP
322 .B \-\-sslproto <name>
323 (Keyword: sslproto)
324 Forces an ssl protocol. Possible values are \&`\fBssl2\fR', `\fBssl3\fR' and
325 `\fBtls1\fR'. Try this if the default handshake does not work for your server.
326 .TP
327 .B \-\-sslcertck
328 (Keyword: sslcertck)
329 Causes fetchmail to strictly check the server certificate against a set of
330 local trusted certificates (see the \fBsslcertpath\fR option). If the server
331 certificate is not signed by one of the trusted ones (directly or indirectly),
332 the SSL connection will fail. This checking should prevent man-in-the-middle
333 attacks against the SSL connection. Note that CRLs are seemingly not currently
334 supported by OpenSSL in certificate verification! Your system clock should
335 be reasonably accurate when using this option!
336 .TP
337 .B \-\-sslcertpath <directory>
338 (Keyword: sslcertpath)
339 Sets the directory fetchmail uses to look up local certificates. The default
340 is your OpenSSL default one. The directory must be hashed as OpenSSL expects
341 it - every time you add or modify a certificate in the directory, you need
342 to use the \fBc_rehash\fR tool (which comes with OpenSSL in the tools/
343 subdirectory).
344 .TP
345 .B \-\-sslfingerprint
346 (Keyword: sslfingerprint)
347 Specify the fingerprint of the server key (an MD5 hash of the key) in
348 hexadecimal notation with colons separating groups of two digits. The letter
349 hex digits must be in upper case. This is the default format OpenSSL uses,
350 and the one fetchmail uses to report the fingerprint when an SSL connection
351 is established. When this is specified, fetchmail will compare the server key
352 fingerprint with the given one, and the connection will fail if they do not
353 match. This can be used to prevent man-in-the-middle attacks.
354 .SS Delivery Control Options
355 .TP
356 .B \-S <hosts> | \-\-smtphost <hosts>
357 (Keyword: smtp[host])
358 Specify a hunt list of hosts to forward mail to (one or more
359 hostnames, comma-separated). Hosts are tried in list order; the first
360 one that is up becomes the forwarding target for the current run.
361 Normally, `localhost' is added to the end of the list as an invisible
362 default.  However, when using Kerberos authentication, the FQDN of the
363 machine running fetchmail is added to the end of the list as an
364 invisible default. Each hostname may have a port number following the
365 host name.  The port number is separated from the host name by a
366 slash; the default port is 25 (or ``smtp'' under IPv6).  If you
367 specify an absolute pathname (beginning with a /), it will be
368 interpreted as the name of a UNIX socket accepting LMTP connections
369 (such as is supported by the Cyrus IMAP daemon) Example:
370 .sp
371 .nf
372         --smtphost server1,server2/2525,server3,/var/imap/socket/lmtp
373 .fi
374 .sp
375 This option can be used with ODMR, and will make fetchmail a relay
376 between the ODMR server and SMTP or LMTP receiver.
377 .TP 
378 .B \-\-fetchdomains <hosts>
379 (Keyword: fetchdomains)
380 In ETRN or ODMR mode, this option specifies the list of domains the
381 server should ship mail for once the connection is turned around.  The
382 default is the FQDN of the machine running 
383 .IR fetchmail .
384 .TP
385 .B \-D <domain> | \-\-smtpaddress <domain>
386 (Keyword: smtpaddress) Specify the domain to be appended to addresses
387 in RCPT TO lines shipped to SMTP. The name of the SMTP server (as
388 specified by --smtphost, or defaulted to "localhost") is used when
389 this is not specified.
390 .TP
391 .B \-\-smtpname <user@domain>
392 (Keyword: smtpname) 
393 Specify the domain and user to be put in RCPT TO lines shipped to SMTP.
394 The default user is the current local user.
395 .TP
396 .B \-Z <nnn> | \-\-antispam <nnn[, nnn]...>
397 (Keyword: antispam) 
398 Specifies the list of numeric SMTP errors that are to be interpreted
399 as a spam-block response from the listener.  A value of -1 disables
400 this option.  For the command-line option, the list values should
401 be comma-separated.
402 .TP
403 .B \-m <command> | \-\-mda <command>
404 (Keyword: mda)
405 You can force mail to be passed to an MDA directly (rather than
406 forwarded to port 25) with the --mda or -m option.  To avoid losing
407 mail, use this option only with MDAs like procmail or sendmail that
408 return a nonzero status on disk-full and other resource-exhaustion
409 errors; the nonzero status tells fetchmail that delivery failed and
410 prevents the message from being deleted off the server.  If
411 \fIfetchmail\fR is running as root, it sets its userid to that of the
412 target user while delivering mail through an MDA.  Some possible MDAs
413 are "/usr/sbin/sendmail -i -f %F %T", "/usr/bin/deliver" and
414 "/usr/bin/procmail -d %T" (but the latter is usually redundant as it's
415 what SMTP listeners normally forward to).  Local delivery addresses
416 will be inserted into the MDA command wherever you place a %T; the
417 mail message's From address will be inserted where you place an %F.
418 Do \fInot\fR use an MDA invocation like "sendmail -i -t" that
419 dispatches on the contents of To/Cc/Bcc, it will create mail loops and
420 bring the just wrath of many postmasters down upon your head.
421 .TP 
422 .B \-\-lmtp
423 (Keyword: lmtp)
424 Cause delivery via LMTP (Local Mail Transfer Protocol).  A service
425 port \fImust\fR be explicitly specified (with a slash suffix) on each
426 host in the smtphost hunt list if this option is selected; the
427 default port 25 will (in accordance with RFC 2033) not be accepted.
428 .TP
429 .B \-\-bsmtp <filename>
430 (keyword: bsmtp)
431 Append fetched mail to a BSMTP file.  This simply contains the SMTP
432 commands that would normally be generated by fetchmail when passing
433 mail to an SMTP listener daemon.  An argument of `-' causes the mail
434 to be written to standard output.  Note that fetchmail's
435 reconstruction of MAIL FROM and RCPT TO lines is not guaranteed
436 correct; the caveats discussed under THE USE AND ABUSE OF MULTIDROP
437 MAILBOXES below apply.
438 .SS Resource Limit Control Options
439 .TP
440 .B \-l <maxbytes> | \-\-limit <maxbytes>
441 (Keyword: limit) Takes a maximum octet size argument.  Messages larger
442 than this size will not be fetched and will be left on the server (in
443 foreground sessions, the progress messages will note that they are
444 "oversized").  If the fetch protocol permits (in particular, under
445 IMAP or POP3 without the fetchall option) the message will not be
446 marked seen An explicit --limit of 0 overrides any limits set in your
447 run control file. This option is intended for those needing to
448 strictly control fetch time due to expensive and variable phone rates.
449 Combined with --flush, it can be used to delete oversized messages
450 waiting on a server.  In daemon mode, oversize notifications are
451 mailed to the calling user (see the --warnings option).  This option
452 does not work with ETRN or ODMR.
453 .TP
454 .B \-w <interval> | \-\-warnings <interval>
455 (Keyword: warnings)
456 Takes an interval in seconds.  When you call
457 .I fetchmail
458 with a `limit' option in daemon mode, this controls the interval at
459 which warnings about oversized messages are mailed to the calling user
460 (or the user specified by the `postmaster' option).  One such
461 notification is always mailed at the end of the the first poll that
462 the oversized message is detected.  Thereafter, renotification is
463 suppressed until after the warning interval elapses (it will take
464 place at the end of the first following poll).
465 .TP
466 .B \-b <count> | \-\-batchlimit <count>
467 (Keyword: batchlimit)
468 Specify the maximum number of messages that will be shipped to an SMTP
469 listener before the connection is deliberately torn down and rebuilt
470 (defaults to 0, meaning no limit).  An explicit --batchlimit of 0
471 overrides any limits set in your run control file.  While
472 \fBsendmail\fR(8) normally initiates delivery of a message immediately
473 after receiving the message terminator, some SMTP listeners are not so
474 prompt.  MTAs like \fIsmail\fR(8) may wait till the
475 delivery socket is shut down to deliver.  This may produce annoying
476 delays when \fIfetchmail\fR is processing very large batches.  Setting
477 the batch limit to some nonzero size will prevent these delays.  This
478 option does not work with ETRN or ODMR.
479 .TP
480 .B \-B <number> | \-\-fetchlimit <number>
481 (Keyword: fetchlimit)
482 Limit the number of messages accepted from a given server in a single
483 poll.  By default there is no limit. An explicit --fetchlimit of 0
484 overrides any limits set in your run control file.
485 This option does not work with ETRN or ODMR.
486 .TP
487 .B \-e <count> | \-\-expunge <count>
488 (keyword: expunge) 
489 Arrange for deletions to be made final after a given number of
490 messages.  Under POP2 or POP3, fetchmail cannot make deletions final
491 without sending QUIT and ending the session -- with this option on,
492 fetchmail will break a long mail retrieval session into multiple
493 subsessions, sending QUIT after each sub-session. This is a good
494 defense against line drops on POP3 servers that do not do the
495 equivalent of a QUIT on hangup.  Under IMAP,
496 .I fetchmail
497 normally issues an EXPUNGE command after each deletion in order to
498 force the deletion to be done immediately.  This is safest when your
499 connection to the server is flaky and expensive, as it avoids
500 resending duplicate mail after a line hit.  However, on large
501 mailboxes the overhead of re-indexing after every message can slam the
502 server pretty hard, so if your connection is reliable it is good to do
503 expunges less frequently.  Also note that some servers enforce a delay
504 of a few seconds after each quit, so fetchmail may not be able to get
505 back in immediately after an expunge -- you may see "lock busy" errors
506 if this happens. If you specify this option to an integer N,
507 it tells
508 .I fetchmail
509 to only issue expunges on every Nth delete.  An argument of zero
510 suppresses expunges entirely (so no expunges at all will be done until
511 the end of run).  This option does not work with ETRN or ODMR.
512 .SS Authentication Options
513 .TP
514 .B \-u <name> | \-\-username <name>
515 (Keyword: user[name])
516 Specifies the user identification to be used when logging in to the mailserver.
517 The appropriate user identification is both server and user-dependent.  
518 The default is your login name on the client machine that is running 
519 .IR fetchmail .
520 See USER AUTHENTICATION below for a complete description.
521 .TP
522 .B \-I <specification> | \-\-interface <specification>
523 (Keyword: interface)
524 Require that a specific interface device be up and have a specific local
525 or remote IP address (or range) before polling.  Frequently
526 .I fetchmail
527 is used over a transient point-to-point TCP/IP link established directly
528 to a mailserver via SLIP or PPP.  That is a relatively secure channel.
529 But when other TCP/IP routes to the mailserver exist (e.g. when the link
530 is connected to an alternate ISP), your username and password may be
531 vulnerable to snooping (especially when daemon mode automatically polls
532 for mail, shipping a clear password over the net at predictable
533 intervals).  The --interface option may be used to prevent this.  When
534 the specified link is not up or is not connected to a matching IP
535 address, polling will be skipped.  The format is:
536 .sp
537 .nf
538         interface/iii.iii.iii.iii/mmm.mmm.mmm.mmm
539 .fi
540 .sp
541 The field before the first slash is the interface name (i.e. sl0, ppp0
542 etc.).  The field before the second slash is the acceptable IP address.
543 The field after the second slash is a mask which specifies a range of
544 IP addresses to accept.  If no mask is present 255.255.255.255 is
545 assumed (i.e. an exact match).  This option is currently only supported
546 under Linux and FreeBSD. Please see the 
547 .B monitor 
548 section for below for FreeBSD specific information.
549 .TP
550 .B \-M <interface> | --monitor <interface>
551 (Keyword: monitor)
552 Daemon mode can cause transient links which are automatically taken down
553 after a period of inactivity (e.g. PPP links) to remain up
554 indefinitely.  This option identifies a system TCP/IP interface to be
555 monitored for activity.  After each poll interval, if the link is up but
556 no other activity has occurred on the link, then the poll will be
557 skipped.  However, when fetchmail is woken up by a signal, the
558 monitor check is skipped and the poll goes through unconditionally.
559 This option is currently only supported under Linux and FreeBSD.
560 For the 
561 .B monitor 
562 and 
563 .B interface
564 options to work for non root users under FreeBSD, the fetchmail binary
565 must be installed SGID kmem. This would be a security hole, but
566 fetchmail runs with the effective GID set to that of the kmem group
567 .I only
568 when interface data is being collected.
569 .TP
570 .B \-\-auth <type>
571 (Keyword: auth[enticate])
572 This option permits you to specify an authentication type (see USER
573 AUTHENTICATION below for details).  The possible values are \fBany\fR,
574 \&`\fBpassword\fR', `\fBkerberos_v5\fR' and `\fBkerberos\fR' (or, for
575 excruciating exactness, `\fBkerberos_v4\fR'), \fRgssapi\fR,
576 \fIcram-md5\fR, \fIotp\fR, \fIntlm\fR, and \fBssh\fR.  When \fBany\fR (the
577 default) is specified, fetchmail tries first methods that don't
578 require a password (GSSAPI, KERBEROS_IV); then it looks for methods
579 that mask your password (CRAM-MD5, X-OTP, NTLM); and only if the server
580 doesn't support any of those will it ship your password en clair.
581 Other values may be used to force various authentication methods
582 (\fBssh\fR suppresses authentication).  Any value other than
583 \fIpassword\fR, \fIcram-md5\fR, \fIntlm\fR or \fIotp\fR suppresses fetchmail's
584 normal inquiry for a password.  Specify \fIssh\fR when you are using
585 an end-to-end secure connection such as an ssh tunnel; specify
586 \fRgssapi\fR or \fBkerberos_v4\fR if you are using a protocol variant
587 that employs GSSAPI or K4.  Choosing KPOP protocol automatically
588 selects Kerberos authentication.  This option does not work with ETRN.
589 .SS Miscellaneous Options
590 .TP
591 .B \-f <pathname> | \-\-fetchmailrc <pathname>
592 Specify a non-default name for the 
593 .I ~/.fetchmailrc
594 run control file.  The pathname argument must be either "-" (a single
595 dash, meaning to read the configuration from standard input) or a
596 filename.  Unless the --version option is also on, a named file
597 argument must have permissions no more open than 0600 (u=rw,g=,o=) or
598 else be /dev/null.
599 .TP
600 .B \-i <pathname> | \-\-idfile <pathname>
601 (Keyword: idfile)
602 Specify an alternate name for the .fetchids file used to save POP3
603 UIDs. 
604 .TP
605 .B \-n | \-\-norewrite
606 (Keyword: no rewrite)
607 Normally,
608 .I fetchmail
609 edits RFC-822 address headers (To, From, Cc, Bcc, and Reply-To) in
610 fetched mail so that any mail IDs local to the server are expanded to
611 full addresses (@ and the mailserver hostname are appended).  This enables 
612 replies on the client to get addressed correctly (otherwise your
613 mailer might think they should be addressed to local users on the
614 client machine!).  This option disables the rewrite.  (This option is
615 provided to pacify people who are paranoid about having an MTA edit
616 mail headers and want to know they can prevent it, but it is generally
617 not a good idea to actually turn off rewrite.)
618 When using ETRN or ODMR, the rewrite option is ineffective.
619 .TP
620 .B \-E <line> | \-\-envelope <line>
621 (Keyword: envelope)
622 This option changes the header 
623 .I fetchmail
624 assumes will carry a copy of the mail's envelope address.  Normally
625 this is `X-Envelope-To' but as this header is not standard, practice
626 varies. See the discussion of multidrop address handling below.  As a
627 special case, `envelope "Received"' enables parsing of sendmail-style
628 Received lines.  This is the default, and it should not be necessary
629 unless you have globally disabled Received parsing with `no envelope'
630 in the \fI.fetchmailrc\fR file.
631 .TP
632 .B \-Q <prefix> | \-\-qvirtual <prefix>
633 (Keyword: qvirtual)
634 The string prefix assigned to this option will be removed from the user
635 name found in the header specified with the \fIenvelope\fR option
636 (\fIbefore\fR doing multidrop name mapping or localdomain checking,
637 if either is applicable). This option is useful if you are using  
638 .I fetchmail
639 to collect the mail for an entire domain and your ISP (or your mail
640 redirection provider) is using qmail.
641 One of the basic features of qmail is the
642 .sp
643 \&`Delivered-To:'
644 .sp
645 message header.  Whenever qmail delivers a message to a local mailbox
646 it puts the username and hostname of the envelope recipient on this
647 line.  The major reason for this is to prevent mail loops.  To set up
648 qmail to batch mail for a disconnected site the ISP-mailhost will have
649 normally put that site in its `Virtualhosts' control file so it will
650 add a prefix to all mail addresses for this site. This results in mail
651 .\" The \&@\& tries to stop HTML converters from making a mailto URL here.
652 sent to 'username\&@\&userhost.userdom.dom.com' having a
653 \&`Delivered-To:' line of the form:
654 .sp
655 Delivered-To: mbox-userstr-username\&@\&userhost.userdom.dom.com
656 .sp
657 The ISP can make the 'mbox-userstr-' prefix anything they choose
658 but a string matching the user host name is likely.
659 By using the option `envelope Delivered-To:' you can make fetchmail reliably
660 identify the original envelope recipient, but you have to strip the
661 `mbox-userstr-' prefix to deliver to the correct user.
662 This is what this option is for.
663 .TP
664 .B --configdump
665 Parse the 
666 .I ~/.fetchmailrc
667 file, interpret any command-line options specified, and dump a
668 configuration report to standard output.  The configuration report is
669 a data structure assignment in the language Python.  This option
670 is meant to be used with an interactive 
671 .I ~/.fetchmailrc
672 editor like 
673 .IR fetchmailconf ,
674 written in Python.
675
676 .SH USER AUTHENTICATION AND ENCRYPTION
677 All modes except ETRN require authentication of the client to the server.
678 Normal user authentication in 
679 .I fetchmail
680 is very much like the authentication mechanism of 
681 .IR ftp (1).
682 The correct user-id and password depend upon the underlying security
683 system at the mailserver.  
684 .PP
685 If the mailserver is a Unix machine on which you have an ordinary user 
686 account, your regular login name and password are used with 
687 .IR fetchmail .
688 If you use the same login name on both the server and the client machines,
689 you needn't worry about specifying a user-id with the 
690 .B \-u
691 option \-\- the default behavior is to use your login name on the
692 client machine as the user-id on the server machine.  If you use a
693 different login name on the server machine, specify that login name
694 with the
695 .B \-u
696 option.  e.g. if your login name is 'jsmith' on a machine named 'mailgrunt',
697 you would start 
698 .I fetchmail 
699 as follows:
700 .IP
701 fetchmail -u jsmith mailgrunt
702 .PP
703 The default behavior of 
704 .I fetchmail
705 is to prompt you for your mailserver password before the connection is
706 established.  This is the safest way to use 
707 .I fetchmail
708 and ensures that your password will not be compromised.  You may also specify
709 your password in your
710 .I ~/.fetchmailrc
711 file.  This is convenient when using 
712 .I fetchmail
713 in daemon mode or with scripts.
714 .PP
715 If you do not specify a password, and
716 .I fetchmail
717 cannot extract one from your
718 .I ~/.fetchmailrc
719 file, it will look for a 
720 .I ~/.netrc
721 file in your home directory before requesting one interactively; if an
722 entry matching the mailserver is found in that file, the password will
723 be used.  Fetchmail first looks for a match on poll name; if it finds none,
724 it checks for a match on via name.  See the
725 .IR ftp (1)
726 man page for details of the syntax of the
727 .I ~/.netrc
728 file.  (This feature may allow you to avoid duplicating password
729 information in more than one file.)
730 .PP
731 On mailservers that do not provide ordinary user accounts, your user-id and 
732 password are usually assigned by the server administrator when you apply for 
733 a mailbox on the server.  Contact your server administrator if you don't know 
734 the correct user-id and password for your mailbox account.
735 .PP
736 Early versions of POP3 (RFC1081, RFC1225) supported a crude form of
737 independent authentication using the
738 .I rhosts
739 file on the mailserver side.  Under this RPOP variant, a fixed
740 per-user ID equivalent to a password was sent in clear over a link to
741 a reserved port, with the command RPOP rather than PASS to alert the
742 server that it should do special checking.  RPOP is supported
743 by
744 .I fetchmail
745 (you can specify `protocol RPOP' to have the program send `RPOP'
746 rather than `PASS') but its use is strongly discouraged.  This
747 facility was vulnerable to spoofing and was withdrawn in RFC1460.
748 .PP
749 RFC1460 introduced APOP authentication.  In this variant of POP3,
750 you register an APOP password on your server host (the program
751 to do this with on the server is probably called \fIpopauth\fR(8)).  You
752 put the same password in your 
753 .I ~/.fetchmailrc
754 file.  Each time 
755 .I fetchmail
756 logs in, it sends a cryptographically secure hash of your password and
757 the server greeting time to the server, which can verify it by
758 checking its authorization database. 
759 .PP
760 If your \fIfetchmail\fR was built with Kerberos support and you specify 
761 Kerberos authentication (either with --auth or the \fI.fetchmailrc\fR
762 option \fBauthenticate kerberos_v4\fR) it will try to get a Kerberos
763 ticket from the mailserver at the start of each query.  Note: if
764 either the pollnane or via name is `hesiod', fetchmail will try to use
765 Hesiod to look up the mailserver.
766 .PP
767 If you use POP3 or IMAP with GSSAPI authentication, \fIfetchmail\fR will
768 expect the server to have RFC1731- or RFC1734-conformant GSSAPI
769 capability, and will use it.  Currently this has only been tested over
770 Kerberos V, so you're expected to already have a ticket-granting
771 ticket. You may pass a username different from your principal name
772 using the standard \fB--user\fR command or by the \fI.fetchmailrc\fR
773 option \fBuser\fR.
774 .PP
775 If your IMAP daemon returns the PREAUTH response in its greeting line, 
776 fetchmail will notice this and skip the normal authentication step.
777 This can be useful, e.g. if you start imapd explicitly using ssh.
778 In this case you can declare the authentication value `ssh' on that
779 site entry to stop \fI.fetchmail\fR from asking you for a password
780 when it starts up.
781 .PP
782 If you are using POP3, and the server issues a one-time-password
783 challenge conforming to RFC1938, \fIfetchmail\fR will use your
784 password as a pass phrase to generate the required response. This
785 avoids sending secrets over the net unencrypted.
786 .PP
787 Compuserve's RPA authentication (similar to APOP) is supported. If you
788 compile in the support, \fIfetchmail\fR will try to perform an RPA pass-phrase
789 authentication instead of sending over the password en clair if it
790 detects "@compuserve.com" in the hostname.
791 .PP
792 If you are using IMAP, Microsoft's NTLM authentication (used by Microsoft
793 Exchange) is supported. If you compile in the support, \fIfetchmail\fR
794 will try to perform an NTLM authentication (instead of sending over the
795 password en clair) whenever the server returns AUTH=NTLM in its
796 capability response. Specify a user option value that looks like
797 `user@domain': the part to the left of the @ will be passed as the
798 username and the part to the right as the NTLM domain.
799 .PP
800 If you are using IPsec, the -T (--netsec) option can be used to pass
801 an IP security request to be used when outgoing IP connections are
802 initialized.  You can also do this using the `netsec' server option
803 in the .fetchmailrc file.  In either case, the option value is a
804 string in the format accepted by the net_security_strtorequest() 
805 function of the inet6_apps library.
806 .PP
807 You can access SSL encrypted services by specifying the --ssl option.
808 You can also do this using the "ssl" server option in the .fetchmailrc
809 file.  With SSL encryption enabled, queries are initiated over a connection
810 after negotiating an SSL session.  Some services, such as POP3 and IMAP,
811 have different well known ports defined for the SSL encrypted services.
812 The encrypted ports will be selected automatically when SSL is enabled and
813 no explicit port is specified.
814 .PP
815 When connecting to an SSL encrypted server, the server presents a certificate
816 to the client for validation.  The certificate is checked to verify that
817 the common name in the certificate matches the name of the server being
818 contacted and that the effective and expiration dates in the certificate
819 indicate that it is currently valid.  If any of these checks fail, a warning
820 message is printed, but the connection continues.  The server certificate
821 does not need to be signed by any specific Certifying Authority and may
822 be a "self-signed" certificate.
823 .PP
824 Some SSL encrypted servers may request a client side certificate.  A client
825 side public SSL certificate and private SSL key may be specified.  If
826 requested by the server, the client certificate is sent to the server for
827 validation.  Some servers may require a valid client certificate and may
828 refuse connections if a certificate is not provided or if the certificate
829 is not valid.  Some servers may require client side certificates be signed
830 by a recognized Certifying Authority.  The format for the key files and
831 the certificate files is that required by the underlying SSL libraries
832 (OpenSSL in the general case).
833 .PP
834 A word of care about the use of SSL: While above mentioned
835 setup with self-signed server certificates retrieved over the wires
836 can protect you from a passive eavesdropper it doesn't help against an
837 active attacker. It's clearly an improvement over sending the
838 passwords in clear but you should be aware that a man-in-the-middle
839 attack is trivially possible (in particular with tools such as dsniff,
840 http://www.monkey.org/~dugsong/dsniff/).  Use of an ssh tunnel (see
841 below for some examples) is preferable if you care seriously about the
842 security of your mailbox.
843 .PP
844 .B fetchmail
845 also supports authentication to the ESMTP server on the client side
846 according to RFC 2554.  You can specify a name/password pair to be
847 used with the keywords `esmtpname' and `esmtppassword'; the former
848 defaults to the username of the calling user.
849
850 .SH DAEMON MODE
851 The 
852 .B \-\-daemon <interval>
853 or
854 .B \-d <interval>
855 option runs 
856 .I fetchmail
857 in daemon mode.  You must specify a numeric argument which is a
858 polling interval in seconds.
859 .PP
860 In daemon mode, 
861 .I fetchmail
862 puts itself in background and runs forever, querying each specified
863 host and then sleeping for the given polling interval.
864 .PP
865 Simply invoking
866 .IP
867 fetchmail -d 900
868 .PP
869 will, therefore, poll all the hosts described in your 
870 .I ~/.fetchmailrc
871 file (except those explicitly excluded with the `skip' verb) once
872 every fifteen minutes.
873 .PP
874 It is possible to set a polling interval 
875 in your
876 .I ~/.fetchmailrc
877 file by saying `set daemon <interval>', where <interval> is an
878 integer number of seconds.  If you do this, fetchmail will always
879 start in daemon mode unless you override it with the command-line
880 option --daemon 0 or -d0.
881 .PP
882 Only one daemon process is permitted per user; in daemon mode,
883 .I fetchmail
884 makes a per-user lockfile to guarantee this.
885 .PP
886 Normally, calling fetchmail with a daemon in the background sends a
887 wakeup signal to the daemon, forcing it to poll mailservers
888 immediately.  (The wakeup signal is SIGHUP if fetchmail is running as
889 root, SIGUSR1 otherwise.)  The wakeup action also clears any `wedged'
890 flags indicating that connections have wedged due to failed 
891 authentication or multiple timeouts.
892 .PP
893 The option
894 .B --quit
895 will kill a running daemon process instead of waking it up (if there
896 is no such process, 
897 .I fetchmail
898 notifies you).  If the --quit option is the only command-line option,
899 that's all there is to it.
900 .PP
901 The quit option may also be mixed with other command-line options; its
902 effect is to kill any running daemon before doing what the other
903 options specify in combination with the rc file.
904 .PP
905 The
906 .B \-L <filename>
907 or
908 .B \-\-logfile <filename>
909 option (keyword: set logfile) allows you to redirect status messages
910 emitted while detached into a specified logfile (follow the
911 option with the logfile name).  The logfile is opened for append, so
912 previous messages aren't deleted.  This is primarily useful for
913 debugging configurations.
914 .PP
915 The
916 .B \-\-syslog
917 option (keyword: set syslog) allows you to redirect status and error
918 messages emitted to the
919 .IR syslog (3)
920 system daemon if available.
921 Messages are logged with an id of \fBfetchmail\fR, the facility \fBLOG_MAIL\fR,
922 and priorities \fBLOG_ERR\fR, \fBLOG_ALERT\fR or \fBLOG_INFO\fR.
923 This option is intended for logging status and error messages which
924 indicate the status of the daemon and the results while fetching mail
925 from the server(s).
926 Error messages for command line options and parsing the \fI.fetchmailrc\fR
927 file are still written to stderr, or to the specified log file.
928 The
929 .B \-\-nosyslog
930 option turns off use of 
931 .IR syslog (3),
932 assuming it's turned on in the 
933 .I ~/.fetchmailrc 
934 file, or that the
935 .B \-L
936 or
937 .B \-\-logfile <file>
938 option was used.
939 .PP
940 The 
941 .B \-N
942 or --nodetach option suppresses backgrounding and detachment of the
943 daemon process from its control terminal.  This is primarily useful
944 for debugging.  Note that this also causes the logfile option to be
945 ignored (though perhaps it shouldn't).
946 .PP
947 Note that while running in daemon mode polling a POP2 or IMAP2bis server,
948 transient errors (such as DNS failures or sendmail delivery refusals)
949 may force the fetchall option on for the duration of the next polling
950 cycle.  This is a robustness feature.  It means that if a message is
951 fetched (and thus marked seen by the mailserver) but not delivered
952 locally due to some transient error, it will be re-fetched during the
953 next poll cycle.  (The IMAP logic doesn't delete messages until
954 they're delivered, so this problem does not arise.)
955 .PP
956 If you touch or change the 
957 .I ~/.fetchmailrc 
958 file while fetchmail is running in daemon mode, this will be detected 
959 at the beginning of the next poll cycle.  When a changed
960 .I ~/.fetchmailrc 
961 is detected, fetchmail rereads it and restarts from scratch (using
962 exec(2); no state information is retained in the new instance).  Note also
963 that if you break the
964 .I ~/.fetchmailrc 
965 file's syntax, the new instance will softly and silently vanish away
966 on startup.
967
968 .SH ADMINISTRATIVE OPTIONS
969 .PP
970 The 
971 .B \-\-postmaster <name>
972 option (keyword: set postmaster) specifies the last-resort username to
973 which multidrop mail is to be forwarded if no matching local recipient
974 can be found.  Normally this is just the user who invoked 
975 .IR fetchmail .
976 If the invoking user is root, then the default of this option is
977 the user `postmaster'.  Setting postmaster to the empty string causes
978 such mail to be discarded.
979 .PP
980 The
981 .B \-\-nobounce
982 option suppresses the normal action of bouncing errors back to the 
983 sender in an RFC1894-conformant error message.  If nobounce is on, the
984 message will go to the postmaster instead.
985 .PP
986 The 
987 .B \-\-invisible
988 option (keyword: set invisible) tries to make fetchmail invisible.
989 Normally, fetchmail behaves like any other MTA would -- it generates a
990 Received header into each message describing its place in the chain of
991 transmission, and tells the MTA it forwards to that the mail came from
992 the machine fetchmail itself is running on.  If the invisible option
993 is on, the Received header is suppressed and fetchmail tries to spoof
994 the MTA it forwards to into thinking it came directly from the
995 mailserver host.
996 .PP
997 The 
998 .B \-\-showdots
999 option (keyword: set showdots) forces fetchmail to show progress dots
1000 even if the current tty is not stdout (for example logfiles).
1001 Starting with fetchmail version 5.3.0, 
1002 progress dots are only shown on stdout by default.
1003 .PP
1004 By specifying the
1005 .B \-\-tracepolls
1006 option, you can ask fetchmail to add information to the Received
1007 header on the form "polling {label} account {user}", where {label} is
1008 the account label (from the specified rcfile, normally ~/.fetchmailrc)
1009 and {user} is the username which is used to log on to the mail
1010 server. This header can be used to make filtering email where no
1011 useful header information is available and you want mail from
1012 different accounts sorted into different mailboxes (this could, for
1013 example, occur if you have an account on the same server running a
1014 mailing list, and are subscribed to the list using that account). The
1015 default is not adding any such header.  In
1016 .IR .fetchmailrc , 
1017 this is called `tracepolls'.
1018
1019 .SH RETRIEVAL FAILURE MODES
1020 The protocols \fIfetchmail\fR uses to talk to mailservers are next to
1021 bulletproof.  In normal operation forwarding to port 25, no message is
1022 ever deleted (or even marked for deletion) on the host until the SMTP
1023 listener on the client side has acknowledged to \fIfetchmail\fR that
1024 the message has been either accepted for delivery or rejected due to a
1025 spam block.
1026 .PP
1027 When forwarding to an MDA, however, there is more possibility
1028 of error.  Some MDAs are `safe' and reliably return a nonzero status
1029 on any delivery error, even one due to temporary resource limits.
1030 The well-known
1031 .IR procmail (1)
1032 program is like this; so are most programs designed as mail transport
1033 agents, such as 
1034 .IR sendmail (1),
1035 and
1036 .IR exim (1).
1037 These programs give back a reliable positive acknowledgement and
1038 can be used with the mda option with no risk of mail loss.  Unsafe
1039 MDAs, though, may return 0 even on delivery failure.  If this
1040 happens, you will lose mail.
1041 .PP
1042 The normal mode of \fIfetchmail\fR is to try to download only `new'
1043 messages, leaving untouched (and undeleted) messages you have already
1044 read directly on the server (or fetched with a previous \fIfetchmail
1045 --keep\fR).  But you may find that messages you've already read on the
1046 server are being fetched (and deleted) even when you don't specify
1047 --all.  There are several reasons this can happen.
1048 .PP
1049 One could be that you're using POP2.  The POP2 protocol includes no
1050 representation of `new' or `old' state in messages, so \fIfetchmail\fR
1051 must treat all messages as new all the time.  But POP2 is obsolete, so
1052 this is unlikely.
1053 .PP
1054 Under POP3, blame RFC1725.  That version of the POP3 protocol
1055 specification removed the LAST command, and some POP servers follow it
1056 (you can verify this by invoking \fIfetchmail -v\fR to the mailserver
1057 and watching the response to LAST early in the query).  The
1058 \fIfetchmail\fR code tries to compensate by using POP3's UID feature,
1059 storing the identifiers of messages seen in each session until the
1060 next session, in the \fI.fetchids\fR file.  But this doesn't track
1061 messages seen with other clients, or read directly with a mailer on
1062 the host but not deleted afterward.  A better solution would be to
1063 switch to IMAP.
1064 .PP
1065 Another potential POP3 problem might be servers that insert messages
1066 in the middle of mailboxes (some VMS implementations of mail are
1067 rumored to do this).  The \fIfetchmail\fR code assumes that new
1068 messages are appended to the end of the mailbox; when this is not true
1069 it may treat some old messages as new and vice versa.  The only 
1070 real fix for this problem is to  switch to IMAP.
1071 .PP
1072 Yet another POP3 problem is that if they can't make tempfiles in the
1073 user's home directory, some POP3 servers will hand back an
1074 undocumented response that causes fetchmail to spuriously report "No
1075 mail".
1076 .PP
1077 The IMAP code uses the presence or absence of the server flag \eSeen
1078 to decide whether or not a message is new.  Under Unix, it counts on
1079 your IMAP server to notice the BSD-style Status flags set by mail user
1080 agents and set the \eSeen flag from them when appropriate.  All Unix
1081 IMAP servers we know of do this, though it's not specified by the IMAP
1082 RFCs.  If you ever trip over a server that doesn't, the symptom will
1083 be that messages you have already read on your host will look new to
1084 the server.  In this (unlikely) case, only messages you fetched with
1085 \fIfetchmail --keep\fR will be both undeleted and marked old.
1086 .PP
1087 In ETRN and ODMR modes, \fIfetchmail\fR does not actually retrieve messages;
1088 instead, it asks the server's SMTP listener to start a queue flush
1089 to the client via SMTP.  Therefore it sends only undelivered messages.
1090
1091 .SH SPAM FILTERING
1092 Many SMTP listeners allow administrators to set up `spam filters' that
1093 block unsolicited email from specified domains.  A MAIL FROM or DATA line that
1094 triggers this feature will elicit an SMTP response which
1095 (unfortunately) varies according to the listener.
1096 .PP
1097 Newer versions of 
1098 .I sendmail
1099 return an error code of 571.  This return value
1100 is blessed by RFC1893 as "Delivery not authorized, message refused".
1101 .PP
1102 According to RFC2821, the correct thing to return in this situation is
1103 550 "Requested action not taken: mailbox unavailable" (the draft adds
1104 "[E.g., mailbox not found, no access, or command rejected for policy
1105 reasons].").
1106 .PP
1107 Older versions of the
1108 .I exim
1109 MTA return 501 "Syntax error in parameters or arguments".
1110 .PP
1111 The
1112 .I postfix
1113 MTA runs 554 as an antispam response.
1114 .PP
1115 .I Zmailer 
1116 may reject code with a 500 response (followed by an enhanced status
1117 code that contains more information).
1118 .PP
1119 Return codes which 
1120 .I fetchmail
1121 treats as antispam responses and discards
1122 the message can be set with the `antispam' option.  This is one of the
1123 .I only
1124 three circumstance under which fetchmail ever discards mail (the others
1125 are the 552 and 553 errors described below, and the suppression of
1126 multidropped messages with a message-ID already seen).
1127 .PP
1128 If
1129 .I fetchmail
1130 is fetching from an IMAP server, the antispam response will be detected and
1131 the message rejected immediately after the headers have been fetched,
1132 without reading the message body.  Thus, you won't pay for downloading 
1133 spam message bodies.
1134 .PP
1135 By default, the list of antispam responses is empty.
1136 .PP
1137 If the \fIspambounce\fR option is on, mail that is spam-blocked
1138 triggers an RFC1892 bounce message informing the originator that we do
1139 not accept mail from it.
1140
1141 .SH SMTP/ESMTP ERROR HANDLING
1142 Besides the spam-blocking described above, fetchmail takes special
1143 actions on the following SMTP/ESMTP error responses
1144 .TP 5
1145 452 (insufficient system storage)
1146 Leave the message in the server mailbox for later retrieval.
1147 .TP 5
1148 552 (message exceeds fixed maximum message size)
1149 Delete the message from the server.  Send bounce-mail to the
1150 originator.
1151 .TP 5
1152 553 (invalid sending domain)
1153 Delete the message from the server.  Don't even try to send
1154 bounce-mail to the originator.
1155 .PP
1156 Other errors trigger bounce mail back to the originator.
1157
1158 .SH THE RUN CONTROL FILE
1159 The preferred way to set up fetchmail is to write a
1160 \&\fI.fetchmailrc\fR file in your home directory (you may do this
1161 directly, with a text editor, or indirectly via \fIfetchmailconf\fR).
1162 When there is a conflict between the command-line arguments and the
1163 arguments in this file, the command-line arguments take precedence.
1164 .PP
1165 To protect the security of your passwords, when --version is not on
1166 your \fI~/.fetchmailrc\fR may not have more than 0600 (u=rw,g=,o=) permissions;
1167 .I fetchmail
1168 will complain and exit otherwise.
1169 .PP
1170 You may read the \fI.fetchmailrc\fR file as a list of commands to 
1171 be executed when 
1172 .I fetchmail
1173 is called with no arguments.
1174 .SS Run Control Syntax
1175 .PP
1176 Comments begin with a '#' and extend through the end of the line.
1177 Otherwise the file consists of a series of server entries or global
1178 option statements in a free-format, token-oriented syntax.
1179 .PP
1180 There are four kinds of tokens: grammar keywords, numbers
1181 (i.e. decimal digit sequences), unquoted strings, and quoted strings.
1182 A quoted string is bounded by double quotes and may contain
1183 whitespace (and quoted digits are treated as a string).  An unquoted
1184 string is any whitespace-delimited token that is neither numeric, string
1185 quoted nor contains the special characters `,', `;', `:', or `='.
1186 .PP
1187 Any amount of whitespace separates tokens in server entries, but is
1188 otherwise ignored. You may use standard C-style escapes (\en, \et,
1189 \eb, octal, and hex) to embed non-printable characters or string
1190 delimiters in strings.
1191 .PP
1192 Each server entry consists of one of the keywords `poll' or `skip',
1193 followed by a server name, followed by server options, followed by any
1194 number of user descriptions.  Note: the most common cause of syntax
1195 errors is mixing up user and server options.
1196 .PP
1197 For backward compatibility, the word `server' is a synonym for `poll'.
1198 .PP
1199 You can use the noise keywords `and', `with',
1200 \&`has', `wants', and `options' anywhere in an entry to make
1201 it resemble English.  They're ignored, but but can make entries much
1202 easier to read at a glance.  The punctuation characters ':', ';' and
1203 \&',' are also ignored.
1204 .PP
1205 .SS Poll vs. Skip
1206 The `poll' verb tells fetchmail to query this host when it is run with
1207 no arguments.  The `skip' verb tells
1208 .I fetchmail 
1209 not to poll this host unless it is explicitly named on the command
1210 line.  (The `skip' verb allows you to experiment with test entries
1211 safely, or easily disable entries for hosts that are temporarily down.)
1212 .PP
1213 .SS Keyword/Option Summary
1214 Here are the legal options.  Keyword suffixes enclosed in
1215 square brackets are optional.  Those corresponding to command-line
1216 options are followed by `-' and the appropriate option letter.
1217
1218 Here are the legal global options:
1219
1220 .TS
1221 l l lw34.
1222 Keyword         Opt     Function
1223 _
1224 set daemon      \&      T{
1225 Set a background poll interval in seconds
1226 T}
1227 set postmaster          \&      T{
1228 Give the name of the last-resort mail recipient
1229 T}
1230 set no bouncemail       \&      T{
1231 Direct error mail to postmaster rather than sender
1232 T}
1233 set no spambounce       \&      T{
1234 Send spam bounces
1235 T}
1236 set logfile     \&      T{
1237 Name of a file to dump error and status messages to
1238 T}
1239 set idfile      \&      T{
1240 Name of the file to store UID lists in
1241 T}
1242 set syslog      \&      T{
1243 Do error logging through syslog(3).
1244 T}
1245 set no syslog   \&      T{
1246 Turn off error logging through syslog(3).
1247 T}
1248 set properties  \&      T{
1249 String value is ignored by fetchmail (may be used by extension scripts)
1250 T}
1251 .TE
1252
1253 Here are the legal server options:
1254
1255 .TS
1256 l l lw34.
1257 Keyword         Opt     Function
1258 _
1259 via             \&      T{
1260 Specify DNS name of mailserver, overriding poll name
1261 T}
1262 proto[col]      -p      T{
1263 Specify protocol (case insensitive):
1264 POP2, POP3, IMAP, APOP, KPOP
1265 T}
1266 local[domains]  \&      T{
1267 Specify domain(s) to be regarded as local
1268 T}
1269 port            -P      T{
1270 Specify TCP/IP service port
1271 T}
1272 auth[enticate]  \&      T{
1273 Set authentication type (default `any')
1274 T}
1275 timeout         -t      T{
1276 Server inactivity timeout in seconds (default 300)
1277 T}
1278 envelope        -E      T{
1279 Specify envelope-address header name
1280 T}
1281 no envelope     \&      T{
1282 Disable looking for envelope address
1283 T}
1284 qvirtual        -Q      T{
1285 Qmail virtual domain prefix to remove from user name
1286 T}
1287 aka             \&      T{
1288 Specify alternate DNS names of mailserver
1289 T}
1290 interface       -I      T{
1291 specify IP interface(s) that must be up for server poll to take place
1292 T}
1293 monitor         -M      T{
1294 Specify IP address to monitor for activity
1295 T}
1296 plugin          \&      T{
1297 Specify command through which to make server connections.
1298 T}
1299 plugout         \&      T{
1300 Specify command through which to make listener connections.
1301 T}
1302 dns             \&      T{
1303 Enable DNS lookup for multidrop (default)
1304 T}
1305 no dns          \&      T{
1306 Disable DNS lookup for multidrop
1307 T}
1308 checkalias      \&      T{
1309 Do comparison by IP address for multidrop
1310 T}
1311 no checkalias   \&      T{
1312 Do comparison by name for multidrop (default)
1313 T}
1314 uidl            -U      T{
1315 Force POP3 to use client-side UIDLs
1316 T}
1317 no uidl         \&      T{
1318 Turn off POP3 use of client-side UIDLs (default)
1319 T}
1320 interval        \&      T{
1321 Only check this site every N poll cycles; N is a numeric argument.
1322 T}
1323 netsec          \&      T{
1324 Pass in IPsec security option request.
1325 T}
1326 principal       \&      T{
1327 Set Kerberos principal (only useful with imap and kerberos)
1328 T}
1329 esmtpname       \&      T{
1330 Set name for RFC2554 authentication to the ESMTP server.
1331 T}
1332 esmtppassword           \&      T{
1333 Set password for RFC2554 authentication to the ESMTP server.
1334 T}
1335 .TE
1336
1337 Here are the legal user options:
1338
1339 .TS
1340 l l lw34.
1341 Keyword         Opt     Function
1342 _
1343 user[name]      -u      T{
1344 Set remote user name 
1345 (local user name if name followed by `here') 
1346 T}
1347 is              \&      T{
1348 Connect local and remote user names
1349 T}
1350 to              \&      T{
1351 Connect local and remote user names
1352 T}
1353 pass[word]      \&      T{
1354 Specify remote account password
1355 T}
1356 ssl             T{
1357 Connect to server over the specified base protocol using SSL encryption
1358 T}
1359 sslcert                 T{
1360 Specify file for client side public SSL certificate
1361 T}
1362 sslkey                  T{
1363 Specify file for client side private SSL key
1364 T}
1365 sslproto                T{
1366 Force ssl protocol for connection
1367 T}
1368 folder          -r      T{
1369 Specify remote folder to query
1370 T}
1371 smtphost        -S      T{
1372 Specify smtp host(s) to forward to
1373 T}
1374 fetchdomains    \&      T{
1375 Specify domains for which mail should be fetched
1376 T}
1377 smtpaddress     -D      T{
1378 Specify the domain to be put in RCPT TO lines
1379 T}
1380 smtpname                T{
1381 Specify the user and domain to be put in RCPT TO lines
1382 T}
1383 antispam        -Z      T{
1384 Specify what SMTP returns are interpreted as spam-policy blocks
1385 T}
1386 mda             -m      T{
1387 Specify MDA for local delivery
1388 T}
1389 bsmtp           -o      T{
1390 Specify BSMTP batch file to append to
1391 T}
1392 preconnect      \&      T{
1393 Command to be executed before each connection
1394 T}
1395 postconnect     \&      T{
1396 Command to be executed after each connection
1397 T}
1398 keep            -k      T{
1399 Don't delete seen messages from server
1400 T}
1401 flush           -F      T{
1402 Flush all seen messages before querying
1403 T}
1404 fetchall        -a      T{
1405 Fetch all messages whether seen or not
1406 T}
1407 rewrite         \&      T{
1408 Rewrite destination addresses for reply (default)
1409 T}
1410 stripcr         \&      T{
1411 Strip carriage returns from ends of lines
1412 T}
1413 forcecr         \&      T{
1414 Force carriage returns at ends of lines
1415 T}
1416 pass8bits       \&      T{
1417 Force BODY=8BITMIME to ESMTP listener
1418 T}
1419 dropstatus      \&      T{
1420 Strip Status and X-Mozilla-Status lines out of incoming mail
1421 T}
1422 dropdelivered   \&      T{
1423 Strip Delivered-To lines out of incoming mail
1424 T}
1425 mimedecode      \&      T{
1426 Convert quoted-printable to 8-bit in MIME messages
1427 T}
1428 idle            \&      T{
1429 Idle waiting for new messages after each poll (IMAP only)
1430 T}
1431 no keep         -K      T{
1432 Delete seen messages from server (default)
1433 T}
1434 no flush        \&      T{
1435 Don't flush all seen messages before querying (default)
1436 T}
1437 no fetchall     \&      T{
1438 Retrieve only new messages (default)
1439 T}
1440 no rewrite      \&      T{
1441 Don't rewrite headers
1442 T}
1443 no stripcr      \&      T{
1444 Don't strip carriage returns (default)
1445 T}
1446 no forcecr      \&      T{
1447 Don't force carriage returns at EOL (default)
1448 T}
1449 no pass8bits    \&      T{
1450 Don't force BODY=8BITMIME to ESMTP listener (default)
1451 T}
1452 no dropstatus   \&      T{
1453 Don't drop Status headers (default)
1454 T}
1455 no dropdelivered        \&      T{
1456 Don't drop Delivered-To headers (default)
1457 T}
1458 no mimedecode   \&      T{
1459 Don't convert quoted-printable to 8-bit in MIME messages (default)
1460 T}
1461 no idle         \&      T{
1462 Don't idle waiting for new messages after each poll (IMAP only)
1463 T}
1464 limit           -l      T{
1465 Set message size limit
1466 T}
1467 warnings        -w      T{
1468 Set message size warning interval
1469 T}
1470 batchlimit      -b      T{
1471 Max # messages to forward in single connect
1472 T}
1473 fetchlimit      -B      T{
1474 Max # messages to fetch in single connect
1475 T}
1476 expunge         -e      T{
1477 Perform an expunge on every #th message (IMAP and POP3 only)
1478 T}
1479 tracepolls      \&      T{
1480 Add poll tracing information to the Received header
1481 T}
1482 properties      \&      T{
1483 String value is ignored by fetchmail (may be used by extension scripts)
1484 T}
1485 .TE
1486 .PP
1487 Remember that all user options must \fIfollow\fR all server options.
1488 .PP
1489 In the .fetchmailrc file, the `envelope' string argument may be
1490 preceded by a whitespace-separated number.  This number, if specified,
1491 is the number of such headers to skip (that is, an argument of 1
1492 selects the second header of the given type).  This is sometime useful
1493 for ignoring bogus Received headers created by an ISP's local delivery
1494 agent.
1495 .SS Keywords Not Corresponding To Option Switches
1496 .PP
1497 The `folder' and `smtphost' options (unlike their command-line
1498 equivalents) can take a space- or comma-separated list of names
1499 following them.
1500 .PP
1501 All options correspond to the obvious command-line arguments, except
1502 the following: `via', `interval', `aka', `is', `to', `dns'/`no dns',
1503 `checkalias'/`no checkalias', `password', `preconnect', `postconnect',
1504 `localdomains', `stripcr'/`no stripcr', `forcecr'/`no forcecr',
1505 `pass8bits'/`no pass8bits' `dropstatus/no dropstatus',
1506 `dropdelivered/no dropdelivered', `mimedecode/no mimedecode', `idle/no
1507 idle', and `no envelope'.
1508 .PP
1509 The `via' option is for if you want to have more
1510 than one configuration pointing at the same site.  If it is present,
1511 the string argument will be taken as the actual DNS name of the 
1512 mailserver host to query.
1513 This will override the argument of poll, which can then simply be a
1514 distinct label for the configuration (e.g. what you would give on the
1515 command line to explicitly query this host).
1516 .PP
1517 The `interval' option (which takes a numeric argument) allows you to poll a
1518 server less frequently than the basic poll interval.  If you say
1519 \&`interval N' the server this option is attached to will only be
1520 queried every N poll intervals. 
1521 .PP
1522 The `is' or `to' keywords associate the following local (client)
1523 name(s) (or server-name to client-name mappings separated by =) with
1524 the mailserver user name in the entry.  If an is/to list has `*' as
1525 its last name, unrecognized names are simply passed through.
1526 .PP
1527 A single local name can be used to support redirecting your mail when
1528 your username on the client machine is different from your name on the
1529 mailserver.  When there is only a single local name, mail is forwarded
1530 to that local username regardless of the message's Received, To, Cc,
1531 and Bcc headers.  In this case 
1532 .I fetchmail
1533 never does DNS lookups.
1534 .PP
1535 When there is more than one local name (or name mapping) the
1536 \fIfetchmail\fR code does look at the Received, To, Cc, and Bcc
1537 headers of retrieved mail (this is `multidrop mode').  It looks for
1538 addresses with hostname parts that match your poll name or your `via',
1539 `aka' or `localdomains' options, and usually also for hostname parts
1540 which DNS tells it are aliases of the mailserver.  See the discussion
1541 of `dns', `checkalias', `localdomains', and `aka' for details on how
1542 matching addresses are handled.
1543 .PP
1544 If \fIfetchmail\fR cannot match any mailserver usernames or
1545 localdomain addresses, the mail will be bounced.
1546 Normally it will be bounced to the sender, but if `nobounce' is on
1547 it will go to the postmaster (which in turn defaults to being the
1548 calling user).
1549 .PP
1550 The `dns' option (normally on) controls the way addresses from
1551 multidrop mailboxes are checked.  On, it enables logic to check each
1552 host address that doesn't match an `aka' or `localdomains' declaration
1553 by looking it up with DNS.  When a mailserver username is recognized
1554 attached to a matching hostname part, its local mapping is added to
1555 the list of local recipients.
1556 .PP
1557 The `checkalias' option (normally off) extends the lookups performed
1558 by the `dns' keyword in multidrop mode, providing a way to cope with
1559 remote MTAs that identify themselves using their canonical name, while
1560 they're polled using an alias.
1561 When such a server is polled, checks to extract the envelope address
1562 fail, and
1563 .IR fetchmail 
1564 reverts to delivery using the To/Cc/Bcc headers (See below 
1565 `Header vs. Envelope addresses'). 
1566 Specifying this option instructs
1567 .IR fetchmail 
1568 to retrieve all the IP addresses associated with both the poll name
1569 and the name used by the remote MTA and to do a comparison of the IP
1570 addresses.  This comes in handy in situations where the remote server
1571 undergoes frequent canonical name changes, that would otherwise
1572 require modifications to the rcfile.  `checkalias' has no effect if
1573 `no dns' is specified in the rcfile.
1574 .PP
1575 The `aka' option is for use with multidrop mailboxes.  It allows you
1576 to pre-declare a list of DNS aliases for a server.  This is an
1577 optimization hack that allows you to trade space for speed.  When
1578 .IR fetchmail ,
1579 while processing a multidrop mailbox, grovels through message headers
1580 looking for names of the mailserver, pre-declaring common ones can
1581 save it from having to do DNS lookups.  Note: the names you give
1582 as arguments to `aka' are matched as suffixes -- if you specify 
1583 (say) `aka netaxs.com', this will match not just a hostnamed
1584 netaxs.com, but any hostname that ends with `.netaxs.com'; such as 
1585 (say) pop3.netaxs.com and mail.netaxs.com.
1586 .PP
1587 The `localdomains' option allows you to declare a list of domains
1588 which fetchmail should consider local.  When fetchmail is parsing
1589 address lines in multidrop modes, and a trailing segment of a host
1590 name matches a declared local domain, that address is passed through
1591 to the listener or MDA unaltered (local-name mappings are \fInot\fR
1592 applied).
1593 .PP
1594 If you are using `localdomains', you may also need to specify \&`no
1595 envelope', which disables \fIfetchmail\fR's normal attempt to deduce
1596 an envelope address from the Received line or X-Envelope-To header or
1597 whatever header has been previously set by `envelope'.  If you set `no
1598 envelope' in the defaults entry it is possible to undo that in
1599 individual entries by using `envelope <string>'.  As a special case,
1600 \&`envelope "Received"' restores the default parsing of
1601 Received lines.
1602 .PP
1603 The \fBpassword\fR option requires a string argument, which is the password
1604 to be used with the entry's server.
1605 .PP
1606 The `preconnect' keyword allows you to specify a shell command to be
1607 executed just before each time
1608 .I fetchmail
1609 establishes a mailserver connection.  This may be useful if you are 
1610 attempting to set up secure POP connections with the aid of
1611 .IR ssh (1).
1612 If the command returns a nonzero status, the poll of that mailserver
1613 will be aborted.
1614 .PP
1615 Similarly, the `postconnect' keyword similarly allows you to specify a
1616 shell command to be executed just after each time a mailserver
1617 connection is taken down.
1618 .PP
1619 The `forcecr' option controls whether lines terminated by LF only are
1620 given CRLF termination before forwarding.  Strictly speaking RFC821
1621 requires this, but few MTAs enforce the requirement it so this option
1622 is normally off (only one such MTA, qmail, is in significant use at
1623 time of writing).  
1624 .PP
1625 The `stripcr' option controls whether carriage returns are stripped
1626 out of retrieved mail before it is forwarded.  It is normally not
1627 necessary to set this, because it defaults to `on' (CR stripping
1628 enabled) when there is an MDA declared but `off' (CR stripping
1629 disabled) when forwarding is via SMTP.  If `stripcr' and `forcecr' are
1630 both on, `stripcr' will override.
1631 .PP
1632 The `pass8bits' option exists to cope with Microsoft mail programs that
1633 stupidly slap a "Content-Transfer-Encoding: 7bit" on everything.  With
1634 this option off (the default) and such a header present, 
1635 .I fetchmail
1636 declares BODY=7BIT to an ESMTP-capable listener; this causes problems for
1637 messages actually using 8-bit ISO or KOI-8 character sets, which will
1638 be garbled by having the high bits of all characters stripped.  If
1639 \&`pass8bits' is on, 
1640 .I fetchmail
1641 is forced to declare BODY=8BITMIME to any ESMTP-capable listener.  If
1642 the listener is 8-bit-clean (as all the major ones now are) the right
1643 thing will probably result.
1644 .PP
1645 The `dropstatus' option controls whether nonempty Status and
1646 X-Mozilla-Status lines are retained in fetched mail (the default) or
1647 discarded.  Retaining them allows your MUA to see what messages (if
1648 any) were marked seen on the server.  On the other hand, it can
1649 confuse some new-mail notifiers, which assume that anything with a
1650 Status line in it has been seen.  (Note: the empty Status lines
1651 inserted by some buggy POP servers are unconditionally discarded.)
1652 .PP
1653 The `dropdelivered' option controls wether Delivered-To headers will
1654 be kept in fetched mail (the default) or discarded. These headers are 
1655 added by Qmail and Postfix mailservers in order to avoid mail loops but
1656 may get in your way if you try to "mirror" a mailserver within the same
1657 domain. Use with caution.
1658 .PP
1659 The `mimedecode' option controls whether MIME messages using the
1660 quoted-printable encoding are automatically converted into pure 8-bit
1661 data. If you are delivering mail to an ESMTP-capable, 8-bit-clean
1662 listener (that includes all of the major MTAs like sendmail), then
1663 this will automatically convert quoted-printable message headers and
1664 data into 8-bit data, making it easier to understand when reading
1665 mail. If your e-mail programs know how to deal with MIME messages,
1666 then this option is not needed.  The mimedecode option is off by
1667 default, because doing RFC2047 conversion on headers throws away
1668 character-set information and can lead to bad results if the encoding
1669 of the headers differs from the body encoding.
1670 .PP
1671 The `idle' option is usable only with IMAP servers supporting the
1672 RFC2177 IDLE command extension.  If it is enabled, and fetchmail
1673 detects that IDLE is supported, an IDLE will be issued at the end
1674 of each poll.  This will tell the IMAP server to hold the connection
1675 open and notify the client when new mail is available.  If you need to
1676 poll a link frequently, IDLE can save bandwidth by eliminating TCP/IP
1677 connects and LOGIN/LOGOUT sequences. On the other hand, an IDLE 
1678 connection will eat almost all of your fetchmail's time, because it
1679 will never drop the connection and allow other pools to occur unless
1680 the server times out the IDLE.  It also doesn't work with multiple 
1681 folders; only the first folder will ever be polled.
1682 .PP
1683 The `properties' option is an extension mechanism.  It takes a string
1684 argument, which is ignored by fetchmail itself.  The string argument may be
1685 used to store configuration information for scripts which require it.
1686 In particular, the output of `--configdump' option will make properties
1687 associated with a user entry readily available to a Python script.
1688 .PP
1689 .SS Miscellaneous Run Control Options
1690 The words `here' and `there' have useful English-like
1691 significance.  Normally `user eric is esr' would mean that 
1692 mail for the remote user `eric' is to be delivered to `esr',
1693 but you can make this clearer by saying `user eric there is esr here',
1694 or reverse it by saying `user esr here is eric there'
1695 .PP
1696 Legal protocol identifiers for use with the `protocol' keyword are:
1697 .sp
1698 .nf
1699     auto (or AUTO)
1700     pop2 (or POP2)
1701     pop3 (or POP3)
1702     sdps (or SDPS)
1703     imap (or IMAP)
1704     apop (or APOP)
1705     kpop (or KPOP)
1706 .fi
1707 .sp
1708 .PP
1709 Legal authentication types are `any', `password', `kerberos', 'kereberos_v5' 
1710 and `gssapi', `cram-md5', `otp', `ntlm', `ssh`.
1711 The `password' type specifies authentication by normal transmission of a
1712 password (the password may be plaintext or subject to
1713 protocol-specific encryption as in APOP); `kerberos' tells
1714 \fIfetchmail\fR to try to get a Kerberos ticket at the start of each
1715 query instead, and send an arbitrary string as the password; and
1716 `gssapi' tells fetchmail to use GSSAPI authentication.  See the description
1717 of the `auth' keyword for more.
1718 .PP
1719 Specifying `kpop' sets POP3 protocol over port 1109 with Kerberos V4
1720 authentication.  These defaults may be overridden by later options.
1721 .PP
1722 There are currently four global option statements; `set logfile'
1723 followed by a string sets the same global specified by --logfile.  A
1724 command-line --logfile option will override this.  Also, `set daemon'
1725 sets the poll interval as --daemon does.  This can be overridden by a
1726 command-line --daemon option; in particular --daemon 0 can be used to
1727 force foreground operation. The `set postmaster' statement sets the
1728 address to which multidrop mail defaults if there are no local
1729 matches.  Finally, `set syslog' sends log messages to syslogd(8).
1730
1731 .SH INTERACTION WITH RFC 822
1732 When trying to determine the originating address of a message,
1733 fetchmail looks through headers in the following order: 
1734 .sp
1735 .nf
1736         Return-Path:
1737         Resent-Sender: (ignored if it doesn't contain an @ or !)
1738         Sender: (ignored if it doesn't contain an @ or !)
1739         Resent-From:
1740         From:
1741         Reply-To:
1742         Apparently-From:
1743 .fi
1744 .sp
1745 The originating address is used for logging, and to set the MAIL FROM
1746 address when forwarding to SMTP.  This order is intended to cope
1747 gracefully with receiving mailing list messages in multidrop mode. The
1748 intent is that if a local address doesn't exist, the bounce message
1749 won't be returned blindly to the author or to the list itself, but
1750 rather to the list manager (which is less annoying).
1751
1752 In multidrop mode, destination headers are processed as follows:
1753 First, fetchmail looks for the Received: header (or whichever one is
1754 specified by the `envelope' option) to determine the local
1755 recipient address. If the mail is addressed to more than one recipient,
1756 the Received line won't contain any information regarding recipient addresses.
1757
1758 Then fetchmail looks for the Resent-To:, Resent-Cc:, and Resent-Bcc:
1759 lines.  If they exists, they should contain the final recipients and
1760 have precedence over their To:/Cc:/Bcc: counterparts.  If the Resent-*
1761 lines doesn't exist, the To:, Cc:, Bcc: and Apparently-To: lines are
1762 looked for. (The presence of a Resent-To: is taken to imply that the
1763 person referred by the To: address has already received the original
1764 copy of the mail).
1765
1766 .SH CONFIGURATION EXAMPLES
1767 Note that although there are password declarations in a good many
1768 of the examples below, this is mainly for illustrative purposes.
1769 We recommend stashing account/password pairs in your $HOME/.netrc
1770 file, where they can be used not just by fetchmail but by ftp(1) and
1771 other programs.
1772
1773 Basic format is:
1774
1775 .nf
1776   poll SERVERNAME protocol PROTOCOL username NAME password PASSWORD 
1777 .fi
1778 .PP
1779 Example:
1780
1781 .nf
1782   poll pop.provider.net protocol pop3 username "jsmith" password "secret1"
1783 .fi
1784 .PP
1785 Or, using some abbreviations:
1786
1787 .nf
1788   poll pop.provider.net proto pop3 user "jsmith" password "secret1"
1789 .fi
1790 .PP
1791 Multiple servers may be listed:
1792
1793 .nf
1794   poll pop.provider.net proto pop3 user "jsmith" pass "secret1"
1795   poll other.provider.net proto pop2 user "John.Smith" pass "My^Hat"
1796 .fi
1797
1798 Here's a version of those two with more whitespace and some noise words: 
1799
1800 .nf
1801   poll pop.provider.net proto pop3
1802       user "jsmith", with password secret1, is "jsmith" here;
1803   poll other.provider.net proto pop2:
1804       user "John.Smith", with password "My^Hat", is "John.Smith" here;
1805 .fi
1806
1807 This version is much easier to read and doesn't cost significantly
1808 more (parsing is done only once, at startup time).
1809
1810 .PP
1811 If you need to include whitespace in a parameter string, enclose the
1812 string in double quotes.  Thus:
1813
1814 .nf
1815   poll mail.provider.net with proto pop3:
1816         user "jsmith" there has password "u can't krak this"
1817                     is jws here and wants mda "/bin/mail"
1818 .fi
1819
1820 You may have an initial server description headed by the keyword
1821 `defaults' instead of `poll' followed by a name.  Such a record
1822 is interpreted as defaults for all queries to use. It may be overwritten
1823 by individual server descriptions.  So, you could write:
1824
1825 .nf
1826   defaults proto pop3
1827         user "jsmith"
1828   poll pop.provider.net
1829         pass "secret1"
1830   poll mail.provider.net
1831         user "jjsmith" there has password "secret2"
1832 .fi
1833
1834 It's possible to specify more than one user per server (this is only
1835 likely to be useful when running fetchmail in daemon mode as root).
1836 The `user' keyword leads off a user description, and every user specification
1837 in a multi-user entry must include it.  Here's an example:
1838
1839 .nf
1840   poll pop.provider.net proto pop3 port 3111
1841         user "jsmith" with pass "secret1" is "smith" here
1842         user jones with pass "secret2" is "jjones" here keep
1843 .fi
1844
1845 This associates the local username `smith' with the pop.provider.net
1846 username `jsmith' and the local username `jjones' with the
1847 pop.provider.net username `jones'.  Mail for `jones' is kept on the
1848 server after download.
1849 .PP
1850 Here's what a simple retrieval configuration for a multi-drop mailbox
1851 looks like:
1852
1853 .nf
1854   poll pop.provider.net:
1855         user maildrop with pass secret1 to golux 'hurkle'='happy' snark here
1856 .fi
1857
1858 This says that the mailbox of account `maildrop' on the server is a
1859 multi-drop box, and that messages in it should be parsed for the
1860 server user names `golux', `hurkle', and `snark'.  It further
1861 specifies that `golux' and `snark' have the same name on the
1862 client as on the server, but mail for server user `hurkle' should be
1863 delivered to client user `happy'.
1864 .PP
1865 Here's an example of another kind of multidrop connection:
1866
1867 .nf
1868   poll pop.provider.net localdomains loonytoons.org toons.org:
1869         user maildrop with pass secret1 to * here
1870 .fi
1871
1872 This also says that the mailbox of account `maildrop' on the server is
1873 a multi-drop box.  It tells fetchmail that any address in the
1874 loonytoons.org or toons.org domains (including subdomain addresses like
1875 `joe@daffy.loonytoons.org') should be passed through to the local SMTP
1876 listener without modification.  Be careful of mail loops if you do this!
1877 .PP
1878 Here's an example configuration using ssh and the plugin option.  The
1879 queries are made directly on the stdin and stdout of imapd via ssh.
1880 Note that in this setup, IMAP authentication can be skipped.
1881
1882 .nf
1883 poll mailhost.net with proto imap:
1884         plugin "ssh %h /usr/sbin/imapd" auth ssh;
1885         user esr is esr here
1886 .fi
1887
1888 .SH THE USE AND ABUSE OF MULTIDROP MAILBOXES
1889 Use the multiple-local-recipients feature with caution -- it can bite.
1890 All multidrop features are ineffective in ETRN and ODMR modes.
1891
1892 Also, note that in multidrop mode duplicate mails are suppressed.  A
1893 piece of mail is considered duplicate if it has the same message-ID as
1894 the message immediately preceding and more than one addressee.  Such
1895 runs of messages may be generated when copies of a message addressed
1896 to multiple users are delivered to a multidrop box.
1897
1898 .SS Header vs. Envelope addresses 
1899 The fundamental problem is that by having your mailserver toss several
1900 peoples' mail in a single maildrop box, you may have thrown away
1901 potentially vital information about who each piece of mail was
1902 actually addressed to (the `envelope address', as opposed to the
1903 header addresses in the RFC822 To/Cc/Bcc headers).  This `envelope
1904 address' is the address you need in order to reroute mail properly.
1905 .PP
1906 Sometimes 
1907 .I fetchmail
1908 can deduce the envelope address.  If the mailserver MTA is
1909 .I sendmail
1910 and the item of mail had just one recipient, the MTA will have written
1911 a `by/for' clause that gives the envelope addressee into its Received
1912 header. But this doesn't work reliably for other MTAs, nor if there is
1913 more than one recipient.  By default, \fIfetchmail\fR looks for
1914 envelope addresses in these lines; you can restore this default with
1915 -E "Received" or \&`envelope Received'.
1916 .PP
1917 Alternatively, some SMTP listeners and/or mail servers insert a header
1918 in each message containing a copy of the envelope addresses.  This
1919 header (when it exists) is often `X-Envelope-To'.  Fetchmail's
1920 assumption about this can be changed with the -E or `envelope' option.
1921 Note that writing an envelope header of this kind exposes the names of
1922 recipients (including blind-copy recipients) to all receivers of the
1923 messages; it is therefore regarded by some administrators as a
1924 security/privacy problem.
1925 .PP
1926 A slight variation of the `X-Envelope-To' header is the `Delivered-To' put
1927 by qmail to avoid mail loops. It will probably prefix the user name with a
1928 string that normally matches the user's domain. To remove this prefix you
1929 can use the -Q or `qvirtual' option.
1930 .PP
1931 Sometimes, unfortunately, neither of these methods works.  When they
1932 all fail, fetchmail must fall back on the contents of To/Cc/Bcc
1933 headers to try to determine recipient addressees -- and these are not
1934 reliable.  In particular, mailing-list software often ships mail with
1935 only the list broadcast address in the To header.
1936 .PP
1937 When
1938 .I fetchmail
1939 cannot deduce a recipient address that is local, and the intended
1940 recipient address was anyone other than fetchmail's invoking user,
1941 mail will get lost.  This is what makes the multidrop feature risky.
1942 .PP
1943 A related problem is that when you blind-copy a mail message, the Bcc
1944 information is carried \fIonly\fR as envelope address (it's not put
1945 in the headers fetchmail can see unless there is an X-Envelope
1946 header).  Thus, blind-copying to someone who gets mail over a
1947 fetchmail link will fail unless the the mailserver host routinely
1948 writes X-Envelope or an equivalent header into messages in your maildrop.
1949
1950 .SS Good Ways To Use Multidrop Mailboxes
1951 Multiple local names can be used to administer a mailing list from the
1952 client side of a \fIfetchmail\fR collection.  Suppose your name is
1953 \&`esr', and you want to both pick up your own mail and maintain a mailing
1954 list called (say) "fetchmail-friends", and you want to keep the alias
1955 list on your client machine.
1956 .PP
1957 On your server, you can alias \&`fetchmail-friends' to `esr'; then, in
1958 your \fI.fetchmailrc\fR, declare \&`to esr fetchmail-friends here'.
1959 Then, when mail including `fetchmail-friends' as a local address
1960 gets fetched, the list name will be appended to the list of
1961 recipients your SMTP listener sees.  Therefore it will undergo alias
1962 expansion locally.  Be sure to include `esr' in the local alias
1963 expansion of fetchmail-friends, or you'll never see mail sent only to
1964 the list.  Also be sure that your listener has the "me-too" option set
1965 (sendmail's -oXm command-line option or OXm declaration) so your name
1966 isn't removed from alias expansions in messages you send.
1967 .PP
1968 This trick is not without its problems, however.  You'll begin to see
1969 this when a message comes in that is addressed only to a mailing list
1970 you do \fInot\fR have declared as a local name.  Each such message
1971 will feature an `X-Fetchmail-Warning' header which is generated
1972 because fetchmail cannot find a valid local name in the recipient
1973 addresses.  Such messages default (as was described above) to being
1974 sent to the local user running
1975 .IR fetchmail ,
1976 but the program has no way to know that that's actually the right thing.
1977
1978 .SS Bad Ways To Abuse Multidrop Mailboxes
1979 Multidrop mailboxes and 
1980 .I fetchmail
1981 serving multiple users in daemon mode do not mix.  The problem, again, is
1982 mail from mailing lists, which typically does not have an individual
1983 recipient address on it.   Unless 
1984 .I fetchmail
1985 can deduce an envelope address, such mail will only go to the account
1986 running fetchmail (probably root).  Also, blind-copied users are very
1987 likely never to see their mail at all.
1988 .PP
1989 If you're tempted to use 
1990 .I fetchmail 
1991 to retrieve mail for multiple users from a single mail drop via POP or
1992 IMAP, think again (and reread the section on header and envelope
1993 addresses above).  It would be smarter to just let the mail sit in the
1994 mailserver's queue and use fetchmail's ETRN or ODMR modes to trigger
1995 SMTP sends periodically (of course, this means you have to poll more
1996 frequently than the mailserver's expiry period).  If you can't arrange
1997 this, try setting up a UUCP feed.
1998 .PP
1999 If you absolutely \fImust\fR use multidrop for this purpose, make sure
2000 your mailserver writes an envelope-address header that fetchmail can
2001 see.  Otherwise you \fIwill\fR lose mail and it \fIwill\fR come back
2002 to haunt you.
2003
2004 .SS Speeding Up Multidrop Checking
2005 Normally, when multiple users are declared 
2006 .I fetchmail
2007 extracts recipient addresses as described above and checks each host
2008 part with DNS to see if it's an alias of the mailserver.  If so, the
2009 name mappings described in the to ... here declaration are done and
2010 the mail locally delivered.
2011 .PP
2012 This is the safest but also slowest method.  To speed it up,
2013 pre-declare mailserver aliases with `aka'; these are checked before
2014 DNS lookups are done.  If you're certain your aka list contains
2015 .B all
2016 DNS aliases of the mailserver (and all MX names pointing at it) 
2017 you can declare `no dns' to suppress DNS lookups entirely and
2018 \fIonly\fR match against the aka list.
2019
2020 .SH EXIT CODES
2021 To facilitate the use of 
2022 .I fetchmail
2023 in shell scripts, an exit code is returned to give an indication
2024 of what occurred during a given connection.
2025 .PP
2026 The exit codes returned by 
2027 .I fetchmail
2028 are as follows:
2029 .IP 0
2030 One or more messages were successfully retrieved (or, if the -c option
2031 was selected, were found waiting but not retrieved).
2032 .IP 1
2033 There was no mail awaiting retrieval.  (There may have been old mail still
2034 on the server but not selected for retrieval.)
2035 .IP 2
2036 An error was encountered when attempting to open a socket to retrieve
2037 mail.  If you don't know what a socket is, don't worry about it --
2038 just treat this as an 'unrecoverable error'.  This error can also be
2039 because a protocol fetchmail wants to use is not listed in /etc/services.
2040 .IP 3
2041 The user authentication step failed.  This usually means that a bad 
2042 user-id, password, or APOP id was specified.  Or it may mean that you 
2043 tried to run fetchmail under circumstances where it did not have
2044 standard input attached to a terminal and could not prompt for a
2045 missing password.
2046 .IP 4
2047 Some sort of fatal protocol error was detected.
2048 .IP 5
2049 There was a syntax error in the arguments to 
2050 .IR fetchmail .
2051 .IP 6
2052 The run control file had bad permissions.
2053 .IP 7
2054 There was an error condition reported by the server.  Can also
2055 fire if
2056 .I fetchmail
2057 timed out while waiting for the server.
2058 .IP 8
2059 Client-side exclusion error.  This means 
2060 .I fetchmail
2061 either found another copy of itself already running, or failed in such
2062 a way that it isn't sure whether another copy is running.
2063 .IP 9
2064 The user authentication step failed because the server responded "lock
2065 busy".  Try again after a brief pause!  This error is not implemented
2066 for all protocols, nor for all servers.  If not implemented for your
2067 server, "3" will be returned instead, see above.  May be returned when
2068 talking to qpopper or other servers that can respond with "lock busy"
2069 or some similar text containing the word "lock".
2070 .IP 10
2071 The 
2072 .I fetchmail
2073 run failed while trying to do an SMTP port open or transaction.
2074 .IP 11
2075 Fatal DNS error.  Fetchmail encountered an error while performing
2076 a DNS lookup at startup and could not proceed.
2077 .IP 12
2078 BSMTP batch file could not be opened.
2079 .IP 13
2080 Poll terminated by a fetch limit (see the --fetchlimit option).
2081 .IP 14
2082 Server busy indication.
2083 .IP 15
2084 Server timed out during an IMAP IDLE.
2085 .IP 23
2086 Internal error.  You should see a message on standard error with
2087 details.
2088 .PP
2089 When
2090 .I fetchmail
2091 queries more than one host, return status is 0 if \fIany\fR query
2092 successfully retrieved mail. Otherwise the returned error status is
2093 that of the last host queried.
2094
2095 .SH FILES
2096 .TP 5
2097 ~/.fetchmailrc
2098 default run control file
2099 .TP 5
2100 ~/.fetchids
2101 default location of file associating hosts with last message IDs seen
2102 (used only with newer RFC1725-compliant POP3 servers supporting the
2103 UIDL command).
2104 .TP 5
2105 ~/.fetchmail.pid
2106 lock file to help prevent concurrent runs (non-root mode).
2107 .TP 5
2108 ~/.netrc 
2109 your FTP run control file, which (if present) will be searched for
2110 passwords as a last resort before prompting for one interactively.
2111 .TP 5
2112 /var/run/fetchmail.pid
2113 lock file to help prevent concurrent runs (root mode, Linux systems).
2114 .TP 5
2115 /etc/fetchmail.pid
2116 lock file to help prevent concurrent runs (root mode, systems without /var/run).
2117
2118 .SH ENVIRONMENT
2119 If the FETCHMAILUSER variable is set, it is used as the name of the
2120 calling user (default local name) for purposes such as mailing error
2121 notifications.  Otherwise, if either the LOGNAME or USER variable is
2122 correctly set (e.g. the corresponding UID matches the session user ID)
2123 then that name is used as the default local name.  Otherwise
2124 \fBgetpwuid\fR(3) must be able to retrieve a password entry for the
2125 session ID (this elaborate logic is designed to handle the case of
2126 multiple names per userid gracefully).
2127
2128 If the environment variable FETCHMAILHOME is set to a valid and
2129 existing directory name, the .fetchmailrc and .fetchids and
2130 \&.fetchmail.pid files are put there instead of in the invoking user's
2131 home directory (and lose the leading dots on their names).  The
2132 \&.netrc file is looked for in the the invoking user's home directory
2133 regardless of FETCHMAILHOME's setting.
2134
2135 .SH SIGNALS
2136 If a
2137 .I fetchmail
2138 daemon is running as root, SIGHUP wakes it up from its sleep phase and
2139 forces a poll of all non-skipped servers (this is in accordance with
2140 the usual conventions for system daemons).
2141 .PP
2142 If
2143 .I fetchmail
2144 is running in daemon mode as non-root, use SIGUSR1 to wake it (this is
2145 so SIGHUP due to logout can retain the default action of killing it).
2146 .PP
2147 Running
2148 .I fetchmail
2149 in foreground while a background fetchmail is running will do
2150 whichever of these is appropriate to wake it up.
2151
2152 .SH BUGS AND KNOWN PROBLEMS
2153 The mda and plugin options interact badly.  In order to collect error
2154 status from the MDA, fetchmail has to change its normal signal
2155 handling so that dead plugin processes don't get reaped until the end
2156 of the poll cycle.  This can cause resource starvation if too many
2157 zombies accumulate.  So either don't deliver to a MDA using plugins or
2158 risk being overrun by an army of undead.
2159 .PP
2160 The RFC822 address parser used in multidrop mode chokes on some
2161 @-addresses that are technically legal but bizarre.  Strange uses of
2162 quoting and embedded comments are likely to confuse it.
2163 .PP
2164 In a message with multiple envelope headers, only the last one
2165 processed will be visible to fetchmail.  To get around this, use a
2166 mailserver-side filter that consolidates the contents of all envelope
2167 headers into a single one (procmail, mailagent, or maildrop can be
2168 programmed to do this fairly easily).
2169 .PP
2170 Use of some of these protocols requires that the program send
2171 unencrypted passwords over the TCP/IP connection to the mailserver.
2172 This creates a risk that name/password pairs might be snaffled with a
2173 packet sniffer or more sophisticated monitoring software.  Under Linux
2174 and FreeBSD, the --interface option can be used to restrict polling to
2175 availability of a specific interface device with a specific local or
2176 remote IP address, but snooping is still possible if (a) either host
2177 has a network device that can be opened in promiscuous mode, or (b)
2178 the intervening network link can be tapped.  We recommend the use of
2179 .IR ssh (1)
2180 tunnelling to not only shroud your passwords but encrypt the entire
2181 conversation.
2182 .PP
2183 Use of the %F or %T escapes in an mda option could open a security
2184 hole, because they pass text manipulable by an attacker to a shell
2185 command.  Potential shell characters are replaced by `_' before
2186 execution.  The hole is further reduced by the fact that fetchmail
2187 temporarily discards any suid privileges it may have while running the
2188 MDA.  For maximum safety, however, don't use an mda command containing
2189 %F or %T when fetchmail is run from the root account itself.
2190 .PP
2191 Fetchmail's method of sending bouncemail and spam bounces requires that
2192 port 25 of localhost be available for sending mail via SMTP.
2193 .PP
2194 If you modify a
2195 .I ~/.fetchmailrc
2196 while a background instance is running and break the syntax, the
2197 background instance will die silently.  Unfortunately, it can't 
2198 die noisily because we don't yet know whether syslog should be enabled.
2199 On some systems, fetchmail dies quietly even if there is no syntax
2200 error; this seems to have something to do with buggy terminal ioctl
2201 code in the kernel.
2202 .PP
2203 The -f - option (reading a configuration from stdin) is incompatible
2204 with the plugin option.
2205 .PP
2206 The UIDL code is generally flaky and tends to lose its state on errors
2207 and line drops (so that old messages are re-seen).  If this happens to
2208 you, switch to IMAP4.
2209 .PP
2210 The `principal' option only handles Kerberos IV, not V.
2211 .PP
2212 Send comments, bug reports, gripes, and the like to the
2213 fetchmail-friends list <fetchmail-friends@lists.ccil.org>.  An HTML FAQ is
2214 available at the fetchmail home page; surf to
2215 http://www.catb.org/~esr/fetchmail or do a WWW search for pages with
2216 `fetchmail' in their titles.
2217
2218 .SH AUTHOR
2219 Eric S. Raymond <esr@snark.thyrsus.com>.  Too many other people to
2220 name here have contributed code and patches. 
2221 This program is descended from and replaces 
2222 .IR popclient , 
2223 by Carl Harris <ceharris@mal.com>; the internals have become quite different, 
2224 but some of its interface design is directly traceable to that
2225 ancestral program.
2226
2227 .SH SEE ALSO
2228 mutt(1), elm(1), mail(1), sendmail(8), popd(8), imapd(8), netrc(5)
2229 .SH APPLICABLE STANDARDS
2230 .TP 5
2231 SMTP/ESMTP:
2232 RFC 821, RFC2821, RFC 1869, RFC 1652, RFC 1870, RFC 1983, RFC 1985,
2233 RFC 2554.
2234 .TP 5
2235 mail:
2236 RFC 822, RFC2822, RFC 1123, RFC 1892, RFC 1894.
2237 .TP 5
2238 POP2:
2239 RFC 937
2240 .TP 5
2241 POP3:
2242 RFC 1081, RFC 1225, RFC 1460, RFC 1725, RFC1734, RFC 1939, RFC 1957,
2243 RFC2195, RFC 2449.
2244 .TP 5
2245 APOP:
2246 RFC 1460, RFC 1725, RFC 1939.
2247 .TP 5
2248 RPOP:
2249 RFC 1081, RFC 1225.
2250 .TP 5
2251 IMAP2/IMAP2BIS:
2252 RFC 1176, RFC 1732.
2253 .TP 5
2254 IMAP4/IMAP4rev1:
2255 RFC 1730, RFC 1731, RFC 1732, RFC 2060, RFC 2061, RFC 2195, RFC 2177,
2256 RFC 2683.
2257 .TP 5
2258 ETRN:
2259 RFC 1985.
2260 .TP 5
2261 ODMR/ATRN:
2262 RFC 2645.
2263 .TP 5
2264 OTP:
2265 RFC 1938.
2266 .TP 5
2267 LMTP:
2268 RFC 2033.
2269 .TP 5
2270 GSSAPI:
2271 RFC 1508.
2272 .TP 5
2273 TLS
2274 RFC 2595.
2275