]> Pileus Git - ~andy/fetchmail/blob - fetchmail.man
Enrico Musio's IP-checkalias patch.
[~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, or ETRN-capable server
10
11 .SH SYNOPSIS
12 \fBfetchmail\fR [\fIoptions\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
19 mail from remote mailservers and forwards it to your local (client)
20 machine's delivery system.  You can then handle the retrieved mail
21 using normal mail user agents such as \fIelm\fR(1) or \fIMail\fR(1).
22 The \fBfetchmail\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, and IMAP4.  It can
29 also use the ESMTP ETRN extension.  (The RFCs describing all these
30 protocols are listed at the end of this document.)
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, or \fIqmail\fR).  All the delivery-control
45 mechanisms (such as \fI.forward\fR files) normally available through
46 your system MDA and local delivery agents will therefore work.
47 .PP
48 If the program
49 .I fetchmailconf
50 is available, it will assist you in setting up and editing a
51 fetchmailrc configuration.  It runs under X and requires that the
52 language Python and the Tk toolkit be present on your system.  If
53 you are first setting up fetchmail for single-user mode, it is
54 recommended that you use Novice mode.  Expert mode provides
55 complete control of fetchmail configuration, including the
56 multidrop features.
57
58 .SH GENERAL OPERATION
59 The behavior of
60 .I fetchmail
61 is controlled by command-line options and a run control file,
62 .IR ~/.fetchmailrc\fR ,
63 the syntax of which we describe in a later section (this file is what
64 the \fIfetchmailconf\fR program edits).  Command-line options override
65 .I ~/.fetchmailrc
66 declarations.
67 .PP
68 Each server name that you specify following the options on the
69 command line will be queried.  If you don't specify any servers
70 on the command line, each server in your 
71 .I ~/.fetchmailrc
72 file will be queried.
73 .PP
74 To facilitate the use of
75 .I fetchmail
76 In scripts, pipelines, etc., it returns an appropriate exit code upon 
77 termination -- see EXIT CODES below.
78 The following options modify the behavior of \fIfetchmail\fR.  It is
79 seldom necessary to specify any of these once you have a
80 working \fI.fetchmailrc\fR file set up.
81 .PP
82 Almost all options have a corresponding keyword which can be used to
83 declare them in a 
84 .I fetchmailrc
85 file.
86 .PP
87 Some special options are not covered here, but are documented insttead
88 in sections on AUTHENTICATION and DAEMON MODE which follows.
89 .SS General Options
90 .TP
91 .B \-V, --version
92 Displays the version information for your copy of 
93 .I fetchmail.
94 No mail fetch is performed.
95 Instead, for each server specified, all option information
96 that would be computed if
97 .I fetchmail.
98 were connecting to that server is displayed.  Any non-printables in
99 passwords or other string names are shown as backslashed C-like
100 escape sequences.  This option is useful for verifying that your
101 options are set the way you want them.
102 .TP
103 .B \-c, --check
104 Return a status code to indicate whether there is mail waiting,
105 without actually fetching or deleting mail (see EXIT CODES below).
106 This option turns off daemon mode (in which it would be useless).  It
107 doesn't play well with queries to multiple sites, and doesn't work
108 with ETRN.  It will return a false positive if you leave read but
109 undeleted mail in your server mailbox and your fetch protocol can't
110 tell kept messages from new ones.  This means it will work with IMAP,
111 not work with POP2, and may occasionally flake out under POP3.
112 .TP
113 .B \-s, --silent
114 Silent mode.  Suppresses all progress/status messages that are normally
115 echoed to standard error during a fetch.  The --verbose option
116 overrides this.
117 .TP
118 .B \-v, --verbose
119 Verbose mode.  All control messages passed between 
120 .I fetchmail
121 and the mailserver are echoed to stderr.  Overrides --silent.
122 .SS Disposal Options
123 .TP
124 .B \-a, --all
125 (Keyword: fetchall)
126 Retrieve both old (seen) and new messages from the mailserver.  The
127 default is to fetch only messages the server has not marked seen.
128 Under POP3, this option also forces the use of RETR rather than TOP.
129 Note that POP2 retrieval behaves as though --all is always on (see
130 RETRIEVAL FAILURE MODES below) and this option does not work with ETRN.
131 .TP
132 .B \-k, --keep
133 (Keyword: keep)
134 Keep retrieved messages on the remote mailserver.  Normally, messages 
135 are deleted from the folder on the mailserver after they have been retrieved.
136 Specifying the 
137 .B keep 
138 option causes retrieved messages to remain in your folder on the
139 mailserver.  This option does not work with ETRN.
140 .TP
141 .B \-K, --nokeep
142 (Keyword: nokeep)
143 Delete retrieved messages from the remote mailserver.  This
144 option forces retrieved mail to be deleted.  It may be useful if
145 you have specified a default of \fBkeep\fR in your
146 \&\fI.fetchmailrc\fR.  This option is forced on with ETRN.
147 .TP
148 .B \-F, --flush
149 POP3/IMAP only.  Delete old (previously retrieved) messages from the mailserver
150 before retrieving new messages. This option does not work with ETRN.
151 Warning: if your local MTA hangs and fetchmail is aborted, the next
152 time you run fetchmail, it will delete mail that was never delivered to you.
153 What you probably want is the default setting: if you don't specify `-k', then
154 fetchmail will automatically delete messages after successful delivery.
155 .SS Protocol and Query Options
156 .TP
157 .B \-p, \--protocol proto
158 (Keyword: proto[col])
159 Specify the protocol to used when communicating with the remote 
160 mailserver.  If no protocol is specified,
161 .I fetchmail
162 will try each of the supported protocols in turn, terminating after
163 any successful attempt.
164 .I proto 
165 may be one of the following:
166 .RS
167 .IP POP2
168 Post Office Protocol 2
169 .IP POP3
170 Post Office Protocol 3
171 .IP APOP
172 Use POP3 with MD5 authentication.
173 .IP RPOP
174 Use POP3 with RPOP authentication.
175 .IP KPOP
176 Use POP3 with Kerberos V4 authentication on port 1109.
177 .IP IMAP
178 IMAP2bis, IMAP4, or IMAP4rev1 (\fIfetchmail\fR autodetects their capabilities).
179 .IP IMAP-K4
180 IMAP4, or IMAP4rev1 (\fIfetchmail\fR autodetects their capabilities)
181 with RFC 1731 Kerberos v4 authentication.
182 .IP IMAP-GSS
183 IMAP4, or IMAP4rev1 (\fIfetchmail\fR autodetects their capabilities)
184 with RFC 1731 GSSAPI authentication.
185 .IP ETRN
186 Use the ESMTP ETRN option.
187 .RE
188 All these alternatives work in basically the same way (communicating
189 with standard server daemons to fetch mail already delivered to a
190 mailbox on the server) except ETRN.  The ETRN mode allows you to ask a
191 compliant ESMTP server (such as BSD sendmail at release 8.8.0 or
192 higher) to immediately open a sender-SMTP connection to your
193 client machine and begin forwarding any items addressed to your client
194 machine in the server's queue of undelivered mail.
195 .TP
196 .B \-U, --uidl
197 (Keyword: uidl)
198 Force UIDL use (effective only with POP3).  Force client-side tracking
199 of `newness' of messages (UIDL stands for ``unique ID listing'' and is
200 described in RFC1725).  Use with `keep' to use a mailbox as a baby
201 news drop for a group of users.
202 .TP
203 .B \-P, --port
204 (Keyword: port)
205 The  option permits you to specify a TCP/IP port to connect on. 
206 This option will seldom be necessary as all the supported protocols have
207 well-established default port numbers.
208 .TP
209 .B \-r folder, --folder folder
210 (Keyword: folder[s])
211 Causes a specified non-default mail folder on the mailserver (or
212 comma-separated list of folders) to be retrieved.  The syntax of the
213 folder name is server-dependent.  This option is not available under
214 POP3 or ETRN.
215 .SS Delivery Control Options
216 .TP
217 .B \-S host, --smtphost host
218 (Keyword: smtp[host])
219 Specify a hunt list of hosts to forward mail to (one or more
220 hostnames, comma-separated).  In ETRN mode, set the host that the
221 mailserver is asked to ship mail to.  Hosts are tried in list order;
222 the first one that is up becomes the forwarding or ETRN target for the
223 current run.  In all modes except ETRN, `localhost' is added to the
224 end of the list as an invisible default.  Each hostname may have a
225 '/'-delimited suffix specifying a port or service to forward to; the
226 default is 25 (or "smtp" under IPv6). 
227 .TP
228 .B \-D domain, --smtpaddress domain
229 (Keyword: smtpaddress) 
230 Specify the domain to be put in RCPT TO lines shipped to SMTP. The
231 name of the SMTP server (as specified by --smtphost, or defaulted to
232 "localhost") is used when this is not specified.
233 .TP
234 .B \-Z nnn, --antispam nnn
235 (Keyword: antispam) 
236 Specifies the numeric SMTP error that is to be interpreted as a
237 spam-block response from the listener.  A value of -1 disables
238 this option.
239 .TP
240 .B \-m, \--mda
241 (Keyword: mda)
242 You can force mail to be passed to an MDA directly (rather than
243 forwarded to port 25) with the -mda or -m option.  If \fIfetchmail\fR
244 is running as root, it sets its userid to that of the target user
245 while delivering mail through an MDA.  Some possible MDAs are
246 "/usr/sbin/sendmail -oem", "/usr/lib/sendmail -oem",
247 "/usr/bin/formail", and "/usr/bin/deliver".  Local delivery addresses
248 will be inserted into the MDA command wherever you place a %T; the
249 mail message's From address will be inserted where you place an %F.  Do
250 \fInot\fR use an MDA invocation like
251 "sendmail -oem -t" that dispatches on the contents of To/Cc/Bcc, it
252 will create mail loops and bring the just wrath of many postmasters
253 down upon your head.
254 .SS Resource Limit Control Options
255 .TP
256 .B \-l, --limit
257 (Keyword: limit)
258 Takes a maximum octet size argument.  Messages larger than this size
259 will not be fetched, not be marked seen, and will be left on the
260 server (in foreground sessions, the progress messages will note that
261 they are "oversized").  An explicit --limit of 0 overrides any limits set
262 in your run control file. This option is intended for those needing to
263 strictly control fetch time in interactive mode.  It may not be used
264 with daemon mode, as users would never receive a notification that
265 messages were waiting.  This option does not work with ETRN.
266 .TP
267 .B -b, --batchlimit
268 (Keyword: batchlimit)
269 Specify the maximum number of messages that will be shipped to an SMTP
270 listener before the connection is deliberately torn down and rebuilt
271 (defaults to 0, meaning no limit).  An explicit --batchlimit of 0
272 overrides any limits set in your run control file.  While
273 \fBsendmail\fR(8) normally initiates delivery of a message immediately
274 after receiving the message terminator, some SMTP listeners are not so
275 prompt.  MTAs like \fIqmail\fR(8) and \fIsmail\fR(8) may wait till the
276 delivery socket is shut down to deliver.  This may produce annoying
277 delays when
278 .IR fetchmail (8)
279 is processing very large batches.  Setting the batch limit to some
280 nonzero size will prevent these delays.
281 This option does not work with ETRN.
282 .TP
283 .B -B, --fetchlimit
284 (Keyword: fetchlimit)
285 Limit the number of messages accepted from a given server in a single
286 poll.  By default there is no limit. An explicit --fetchlimit of 0
287 overrides any limits set in your run control file.
288 This option does not work with ETRN.
289 .TP
290 .B -e, --expunge
291 (keyword: expunge)
292 When talking to an IMAP server, 
293 .I fetchmail
294 normally issues an EXPUNGE command after each deletion in order to
295 force the deletion to be done immediately.  This is safest when your
296 connection to the server is flaky and expensive, as it avoids
297 resending duplicate mail after a line hit.  However, on large
298 mailboxes the overhead of re-indexing after every message can slam the
299 server pretty hard, so if your connection is reliable it is good to do
300 expunges less frequently.  If you specify this option to an integer N,
301 it tells
302 .I fetchmail
303 to only issue expunges on every Nth delete.  An argument
304 of zero suppresses expunges entirely (so no expunges at all will be
305 done until the end of run). 
306 This option does not work with ETRN, POP2, or POP3.
307 .SS Authentication Options
308 .TP
309 .B \-u name, --username name
310 (Keyword: user[name])
311 Specifies the user identification to be used when logging in to the mailserver.
312 The appropriate user identification is both server and user-dependent.  
313 The default is your login name on the client machine that is running 
314 .I fetchmail.
315 See USER AUTHENTICATION below for a complete description.
316 .TP
317 .B \-I specification, --interface specification
318 (Keyword: interface)
319 Require that a specific interface device be up and have a specific local
320 IP address (or range) before polling.  Frequently
321 .I fetchmail
322 is used over a transient point-to-point TCP/IP link established directly
323 to a mailserver via SLIP or PPP.  That is a relatively secure channel.
324 But when other TCP/IP routes to the mailserver exist (e.g. when the link
325 is connected to an alternate ISP), your username and password may be
326 vulnerable to snooping (especially when daemon mode automatically polls
327 for mail, shipping a clear password over the net at predictable
328 intervals).  The --interface option may be used to prevent this.  When
329 the specified link is not up or is not connected to a matching IP
330 address, polling will be skipped.  The format is:
331 .sp
332         interface/iii.iii.iii.iii/mmm.mmm.mmm.mmm
333 .sp
334 The field before the first slash is the interface name (i.e. sl0, ppp0
335 etc.).  The field before the second slash is the acceptable IP address.
336 The field after the second slash is a mask which specifies a range of
337 IP addresses to accept.  If no mask is present 255.255.255.255 is
338 assumed (i.e. an exact match).  This option is currently only supported
339 under Linux.
340 .TP
341 .B \-M interface, --monitor interface
342 (Keyword: monitor)
343 Daemon mode can cause transient links which are automatically taken down
344 after a period of inactivity (e.g. PPP links) to remain up
345 indefinitely.  This option identifies a system TCP/IP interface to be
346 monitored for activity.  After each poll interval, if the link is up but
347 no other activity has occurred on the link, then the poll will be
348 skipped.  This option is currently only supported under Linux.
349 .TP
350 .B \-A, --auth
351 (Keyword: auth[enticate]) 
352 This option permits you to specify a preauthentication type (see USER
353 AUTHENTICATION below for details).  The possible values are
354 \&`\fBpassword\fR', `\fBkerberos_v5\fR' and `\fBkerberos\fR' (or, for
355 excruciating exactness, `\fBkerberos_v4\fR').  This option is provided
356 primarily for developers; choosing KPOP protocol automatically selects
357 Kerberos preauthentication, and all other alternatives use password
358 authentication (though APOP uses a generated one-time key as the
359 password and IMAP-K4 uses RFC1731 Kerberos v4 authentication).  This
360 option does not work with ETRN.
361 .SS Miscellaneous Options
362 .TP
363 .B \-f pathname, --fetchmailrc pathname
364 Specify a non-default name for the 
365 .I .fetchmailrc
366 run control file.  Unless the --version option is also on, the file must have
367 permissions no more open than  0600 (u=rw,g=,o=) or else be /dev/null.
368 .TP
369 .B \-i pathname, --idfile pathname
370 (Keyword: idfile)
371 Specify an alternate name for the .fetchids file used to save POP3
372 UIDs. 
373 .TP
374 .B \-n, --norewrite
375 (Keyword: no rewrite)
376 Normally,
377 .I fetchmail
378 edits RFC-822 address headers (To, From, Cc, Bcc, and Reply-To) in
379 fetched mail so that any mail IDs local to the server are expanded to
380 full addresses (@ and the mailserver hostname are appended).  This enables 
381 replies on the client to get addressed correctly (otherwise your
382 mailer might think they should be addressed to local users on the
383 client machine!).  This option disables the rewrite.  (This option is
384 provided to pacify people who are paranoid about having an MTA edit
385 mail headers and want to know they can prevent it, but it is generally
386 not a good idea to actually turn off rewrite.)
387 When using ETRN, the rewrite option is ineffective.
388 .TP
389 .B -E, --envelope
390 (Keyword: envelope)
391 This option changes the header 
392 .I fetchmail
393 assumes will carry a copy of the mail's envelope address.  Normally
394 this is `X-Envelope-To' but as this header is not standard, practice
395 varies. See the discussion of multidrop address handling below.  As a
396 special case, `envelope "Received"' enables parsing of sendmail-style
397 Received lines.  This is the default, and it should not be necessary
398 unless you have globally disabled Received parsing with `no envelope'
399 in the \fI.fetchmailrc\fR file.
400 .TP
401 .B -Q, --qvirtual
402 (Keyword: qvirtual)
403 The string prefix assigned to this option will be removed from the user
404 name found in the header specified with the \fIenvelope\fR option
405 (\fIbefore\fR doing multidrop name mapping or localdomain checking,
406 if either is applicable). This option is useful if you are using  
407 .I fetchmail
408 to collect the mail for an entire domain and your ISP (or your mail
409 redirection provider) is using qmail.
410 One of the basic features of qmail is the
411 .sp
412 \&`Delivered-To:'
413 .sp
414 message header.  Whenever qmail delivers a message to a local mailbox
415 it puts the username and hostname of the envelope recipient on this
416 line.  The major reason for this is to prevent mail loops.  To set up
417 qmail to batch mail for a disconnected site the ISP-mailhost will have
418 normally put that site in its `Virtualhosts' control file so it will
419 add a prefix to all mail addresses for this site. This results in mail
420 sent to 'username@userhost.userdom.dom.com' having a
421 \&`Delivered-To:' line of the form:
422 .sp
423 Delivered-To: mbox-userstr-username@userhost.userdom.dom.com
424 .sp
425 The ISP can make the 'mbox-userstr-' prefix anything they choose
426 but a string matching the user host name is likely.
427 By using the option `envelope Delivered-To:' you can make fetchmail reliably
428 identify the original envelope recipient, but you have to strip the
429 `mbox-userstr-' prefix to deliver to the correct user.
430 This is what this option is for.
431 .TP
432 .B --configdump
433 Parse the 
434 .I ~/.fetchmailrc
435 file, interpret any command-line options specified, and dump a
436 configuration report to standard output.  The configuration report is
437 a data structure assignment in the language Python.  This option
438 is meant to be used with an interactive 
439 .I ~/.fetchmailrc
440 editor written in Python.
441
442 .SH USER AUTHENTICATION AND ENCRYPTION
443 Every mode except ETRN requires authentication of the client.
444 Normal user authentication in 
445 .I fetchmail
446 is very much like the authentication mechanism of 
447 .IR ftp (1).
448 The correct user-id and password depend upon the underlying security
449 system at the mailserver.  
450 .PP
451 If the mailserver is a Unix machine on which you have an ordinary user 
452 account, your regular login name and password are used with 
453 .I fetchmail.
454 If you use the same login name on both the server and the client machines,
455 you needn't worry about specifying a user-id with the 
456 .B \-u
457 option \-\- 
458 the default behavior is to use your login name on the client machine as the 
459 user-id on the server machine.  If you use a different login name
460 on the server machine, specify that login name with the
461 .B \-u
462 option.  e.g. if your login name is 'jsmith' on a machine named 'mailgrunt',
463 you would start 
464 .I fetchmail 
465 as follows:
466 .IP
467 fetchmail -u jsmith mailgrunt
468 .PP
469 The default behavior of 
470 .I fetchmail
471 is to prompt you for your mailserver password before the connection is
472 established.  This is the safest way to use 
473 .I fetchmail
474 and ensures that your password will not be compromised.  You may also specify
475 your password in your
476 .I ~/.fetchmailrc
477 file.  This is convenient when using 
478 .I fetchmail
479 in daemon mode or with scripts.
480 .PP
481 If you do not specify a password, and
482 .I fetchmail
483 cannot extract one from your
484 .I .fetchmailrc
485 file, it will look for a 
486 .I .netrc
487 file in your home directory before requesting one interactively; if an
488 entry matching the mailserver is found in that file, the password will
489 be used.  See the
490 .IR ftp (1)
491 man page for details of the syntax of the
492 .I .netrc
493 file.  (This feature may allow you to avoid duplicating password
494 information in more than one file.)
495 .PP
496 On mailservers that do not provide ordinary user accounts, your user-id and 
497 password are usually assigned by the server administrator when you apply for 
498 a mailbox on the server.  Contact your server administrator if you don't know 
499 the correct user-id and password for your mailbox account.
500 .PP
501 Early versions of POP3 (RFC1081, RFC1225) supported a crude form of
502 independent authentication using the
503 .I rhosts
504 file on the mailserver side.  Under this RPOP variant, a fixed
505 per-user ID equivalent to a password was sent in clear over a link to
506 a reserved port, with the command RPOP rather than PASS to alert the
507 server that it should do special checking.  RPOP is supported
508 by
509 .I fetchmail
510 (you can specify `protocol RPOP' to have the program send `RPOP'
511 rather than `PASS') but its use is strongly discouraged.  This
512 facility was vulnerable to spoofing and was withdrawn in RFC1460.
513 .PP
514 RFC1460 introduced APOP authentication.  In this variant of POP3,
515 you register an APOP password on your server host (the program
516 to do this with on the server is probably called \fIpopauth\fR(8)).  You
517 put the same password in your 
518 .I .fetchmailrc
519 file.  Each time 
520 .I fetchmail
521 logs in, it sends a cryptographically secure hash of your password and
522 the server greeting time to the server, which can verify it by
523 checking its authorization database. 
524 .PP
525 If your \fIfetchmail\fR was built with Kerberos support and you specify 
526 Kerberos preauthentication (either with --auth or the \fI.fetchmailrc\fR
527 option \fBauthenticate kerberos_v4\fR) it will try to get a Kerberos
528 ticket from the mailserver at the start of each query. 
529 .PP
530 If you use IMAP-K4, \fIfetchmail\fR will expect the IMAP server to have
531 RFC1731-conformant AUTHENTICATE KERBEROS_V4 capability, and will use it.
532 .PP
533 If you use IMAP-GSS, \fIfetchmail\fR will expect the IMAP server to have
534 RFC1731-conformant AUTHENTICATE GSSAPI capability, and will use it. 
535 Currently this has only been tested over Kerberos V, so you're expected
536 to already have a ticket-granting ticket. You may pass a username different
537 from your principal name using the standard \fB--user\fR command or by
538 the \fI.fetchmailrc\fR option \fBuser\fR.
539 .PP
540 If you are using POP3, and the server issues a one-time-password
541 challenge conforming to RFC1938, \fIfetchmail\fR will use your
542 password as a pass phrase to generate the required response. This
543 avoids sending secrets over the net unencrypted.
544 .PP
545 Compuserve's RPA authentication (similar to APOP) is supported.  If
546 you are using POP3, and the RPA code has been compiled into your
547 binary, and you query a server in the Compuserve csi.com domain,
548 \fIfetchmail\fR will try to perform an RPA pass-phrase authentication
549 instead of sending over the password en clair.
550 .PP
551 If you are using IPsec, the -T (--netsec) option can be used to pass
552 an IP security request to be used when outgoing IP connections are
553 initialized.  You can also do this using the `netsec' server option
554 in the .fetchmailrc file.  In either case, the option value is a
555 string in the format accepted by the net_security_strtorequest() 
556 function of the inet6_apps library.
557
558 .SH DAEMON MODE
559 The 
560 .B --daemon
561 or
562 .B -d 
563 option runs 
564 .I fetchmail
565 in daemon mode.  You must specify a numeric argument which is a
566 polling interval in seconds.
567 .PP
568 In daemon mode, 
569 .I fetchmail
570 puts itself in background and runs forever, querying each specified
571 host and then sleeping for the given polling interval.
572 .PP
573 Simply invoking
574 .IP
575 fetchmail -d 900
576 .PP
577 will, therefore, poll all the hosts described in your 
578 .I ~/.fetchmailrc
579 file (except those explicitly excluded with the `skip' verb) once
580 every fifteen minutes.
581 .PP
582 It is possible to set a polling interval 
583 in your
584 .I ~/.fetchmailrc
585 file by saying `set daemon <interval>', where <interval> is an
586 integer number of seconds.  If you do this, fetchmail will always
587 start in daemon mode unless you override it with the command-line
588 option --daemon 0 or -d0.
589 .PP
590 Only one daemon process is permitted per user; in daemon mode,
591 .I fetchmail
592 makes a per-user lockfile to guarantee this.
593 .PP
594 Normally, calling fetchmail with a daemon in the background sends a
595 wakeup signal to the daemon, forcing it to poll mailservers
596 immediately.  (The wakeup signal is SIGHUP if fetchmail is running as
597 root, SIGUSR1 otherwise.)
598 .PP
599 The option
600 .B --quit
601 will kill a running daemon process instead of waking it up (if there
602 is no such option, 
603 .I fetchmail
604 notifies you).  If the --quit option is the only command-line option,
605 that's all there is to it.
606 .PP
607 The quit option may also be mixed with other command-line options; its
608 effect is to kill any running daemon before doing what the other
609 options specify in combination with the rc file.
610 .PP
611 The 
612 .B -t
613 or
614 .B --timeout
615 option (keyword: timeout) allows you to set a server-nonresponse
616 timeout in seconds.  If a mailserver does not send a greeting message
617 or respond to commands for the given number of seconds,
618 \fIfetchmail\fR will hang up on it.  Without such a timeout
619 \fIfetchmail\fR might hang up indefinitely trying to fetch mail from a
620 down host.  This would be particularly annoying for a \fIfetchmail\fR
621 running in background.  There is a default timeout which fetchmail -V
622 will report.
623 .PP
624 The
625 .B -L
626 or
627 .B --logfile
628 option (keyword: set logfile) allows you to redirect status messages
629 emitted while detached into a specified logfile (follow the
630 option with the logfile name).  The logfile is opened for append, so
631 previous messages aren't deleted.  This is primarily useful for
632 debugging configurations.
633 .PP
634 The
635 .B --syslog
636 option (keyword: set syslog) allows you to redirect status and error
637 messages emitted to the
638 .IR syslog (3)
639 system daemon if available.
640 Messages are logged with an id of \fBfetchmail\fR, the facility \fBLOG_MAIL\fR,
641 and priorities \fBLOG_ERR\fR, \fBLOG_ALERT\fR or \fBLOG_INFO\fR.
642 This option is intended for logging status and error messages which
643 indicate the status of the daemon and the results while fetching mail
644 from the server(s).
645 Error messages for command line options and parsing the \fI.fetchmailrc\fR
646 file are still written to stderr, or the specified log file if the
647 .B -L
648 or
649 .B --logfile
650 option was used.
651 .PP
652 The 
653 .B --invisible
654 option (keyword: set invisible) tries to make fetchmail invisible.
655 Normally, fetchmail behaves like any other MTA would -- it generates a
656 Received header into each message describing its place in the chain of
657 transmission, and tells the MTA it forwards to that the mail came from
658 the machine fetchmail itself is running on.  If the invisible option
659 is on, the Received header is suppressed and fetchmail tries to spoof
660 the MTA it forwards to into thinking it came directly from the
661 mailserver host.
662 .PP
663 The 
664 .B \-N
665 or --nodetach option suppresses backgrounding and detachment of the
666 daemon process from its control terminal.  This is primarily useful
667 for debugging.  Note that this also causes the logfile option to be
668 ignored (though perhaps it shouldn't).
669 .PP
670 Note that while running in daemon mode polling a POP2 or IMAP2bis server,
671 transient errors (such as DNS failures or sendmail delivery refusals)
672 may force the fetchall option on for the duration of the next polling
673 cycle.  This is a robustness feature.  It means that if a message is
674 fetched (and thus marked seen by the mailserver) but not delivered
675 locally due to some transient error, it will be re-fetched during the
676 next poll cycle.  (The IMAP logic doesn't delete messages until
677 they're delivered, so this problem does not arise.)
678
679 .SH RETRIEVAL FAILURE MODES
680 The protocols \fIfetchmail\fR uses to talk to mailservers are next to
681 bulletproof.  In normal operation forwarding to port 25, no message is
682 ever deleted (or even marked for deletion) on the host until the SMTP
683 listener on the client has acknowledged to \fIfetchmail\fR that the
684 message has been accepted for delivery.  When forwarding to an MDA,
685 however, there is more possibility of error (because there's no way
686 for fetchmail to get a reliable positive acknowledgement from the MDA).
687 .PP
688 The normal mode of \fIfetchmail\fR is to try to download only `new'
689 messages, leaving untouched (and undeleted) messages you have already
690 read directly on the server (or fetched with a previous \fIfetchmail
691 --keep\fR).  But you may find that messages you've already read on the
692 server are being fetched (and deleted) even when you don't specify
693 --all.  There are several reasons this can happen.
694 .PP
695 One could be that you're using POP2.  The POP2 protocol includes no
696 representation of `new' or `old' state in messages, so \fIfetchmail\fR
697 must treat all messages as new all the time.  But POP2 is obsolete, so
698 this is unlikely.
699 .PP
700 Under POP3, blame RFC1725.  That version of the POP3 protocol
701 specification removed the LAST command, and some POP servers follow it
702 (you can verify this by invoking \fIfetchmail -v\fR to the mailserver
703 and watching the response to LAST early in the query).  The
704 \fIfetchmail\fR code tries to compensate by using POP3's UID feature,
705 storing the identifiers of messages seen in each session until the
706 next session, in the \fI.fetchids\fR file.  But this doesn't track
707 messages seen with other clients, or read directly with a mailer on
708 the host but not deleted afterward.  A better solution would be to
709 switch to IMAP.
710 .PP
711 Another potential POP3 problem might be servers that insert messages
712 in the middle of mailboxes (some VMS implementations of mail are
713 rumored to do this).  The \fIfetchmail\fR code assumes that new
714 messages are appended to the end of the mailbox; when this is not true
715 it may treat some old messages as new and vice versa.  The only 
716 real fix for this problem is to  switch to IMAP.
717 .PP
718 The IMAP code uses the presence or absence of the server flag \eSeen
719 to decide whether or not a message is new.  Under Unix, it counts on
720 your IMAP server to notice the BSD-style Status flags set by mail user
721 agents and set the \eSeen flag from them when appropriate.  All Unix
722 IMAP servers we know of do this, though it's not specified by the IMAP
723 RFCs.  If you ever trip over a server that doesn't, the symptom will
724 be that messages you have already read on your host will look new to
725 the server.  In this (unlikely) case, only messages you fetched with
726 \fIfetchmail --keep\fR will be both undeleted and marked old.
727 .PP
728 In ETRN mode, \fIfetchmail\fR does not actually retrieve messages;
729 instead, it asks the server's SMTP listener to start a queue flush
730 to the client via SMTP.  Therefore it sends only undelivered messages.
731
732 .SH SPAM FILTERING
733 Many SMTP listeners allow administrators to set up `spam filters' that
734 block unsolicited email from specified domains.  A MAIL FROM line that
735 triggers this feature will elicit an SMTP response which
736 (unfortunately) varies according to the listener.
737 .PP
738 Newer versions of 
739 .I sendmail
740 return an error code of 571.  This return value
741 is blessed by RFC1893 as "Delivery not authorized, message refused".
742 .PP
743 According to current drafts of the replacement for RFC821, the correct
744 thing to return in this situation is 550 "Requested action not taken:
745 mailbox unavailable" (the draft adds "[E.g., mailbox not found, no
746 access, or command rejected for policy reasons].").
747 .PP
748 The
749 .I exim
750 MTA returns 501 "Syntax error in parameters or arguments" , but will
751 move to 550 soon.
752 .PP
753 The
754 .I fetchmail
755 code recognizes and discards the message on a code that defaults to
756 sendmail's 571 but can be set with the `antispam' option.  This is the
757 .I only
758 circumstance under which fetchmail ever discards mail.
759 .P
760 If
761 .I fetchmail
762 is fetching from an IMAP server, the antispam response will be detected and
763 the message rejected immediately after the headers have been fetched,
764 without reading the message body.  Thus, you won't pay for downloading 
765 spam message bodies.
766
767 .SH THE RUN CONTROL FILE
768 The preferred way to set up fetchmail is to write a
769 \&\fI.fetchmailrc\fR file in your home directory.  When there is a
770 conflict between the command-line arguments and the arguments in this
771 file, the command-line arguments take precedence.
772 .PP
773 To protect the security of your passwords, when --version is not on
774 your \fI~/.fetchmailrc\fR may not have more than 0600 (u=rw,g=,o=) permissions;
775 .I fetchmail
776 will complain and exit otherwise.
777 .PP
778 You may read the \fI.fetchmailrc\fR file as a list of commands to 
779 be executed when 
780 .I fetchmail
781 is called with no arguments.
782 .SS Run Control Syntax
783 .PP
784 Comments begin with a '#' and extend through the end of the line.
785 Otherwise the file consists of a series of server entries or global
786 option statements in a free-format, token-oriented syntax.
787 .PP
788 There are four kinds of tokens: grammar keywords, numbers
789 (i.e. decimal digit sequences), unquoted strings, and quoted strings.
790 A quoted string is bounded by double quotes and may contain
791 whitespace (and quoted digits are treated as a string).  An unquoted
792 string is any whitespace-delimited token that is neither numeric, string
793 quoted nor contains the special characters `,', `;', `:', or `='.
794 .PP
795 Any amount of whitespace separates tokens in server entries, but is
796 otherwise ignored. You may use standard C-style escapes (\en, \et,
797 \eb, octal, and hex) to embed non-printable characters or string
798 delimiters in strings.
799 .PP
800 Each server entry consists of one of the keywords `poll' or `skip',
801 followed by a server name, followed by server options, followed by any
802 number of user descriptions.  Note: the most common cause of syntax
803 errors is mixing up user and server options.
804 .PP
805 For backward compatibility, the word `server' is a synonym for `poll'.
806 .PP
807 You can use the noise keywords `and', `with',
808 \&`has', `wants', and `options' anywhere in an entry to make
809 it resemble English.  They're ignored, but but can make entries much
810 easier to read at a glance.  The punctuation characters ':', ';' and
811 \&',' are also ignored.
812 .PP
813 .SS Poll vs. Skip
814 The `poll' verb tells fetchmail to query this host when it is run with
815 no arguments.  The `skip' verb tells
816 .I fetchmail 
817 not to poll this host unless it is explicitly named on the command
818 line.  (The `skip' verb allows you to experiment with test entries
819 safely, or easily disable entries for hosts that are temporarily down.)
820 .PP
821 .SS Keyword/Option Summary
822 Here are the legal server options.  Keyword suffixes enclosed in
823 square brackets are optional.  Those corresponding to command-line
824 options are followed by `-' and the appropriate option letter.
825
826 .TS
827 l l lw34.
828 Keyword         Opt     Function
829 _
830 via             \&      T{
831 Specify DNS name of mailserver, overriding poll name
832 T}
833 proto[col]      -p      T{
834 Specify protocol (case insensitive):
835 POP2, POP3, IMAP, IMAP-K4, IMAP-GSS, APOP, KPOP
836 T}
837 port            -P      T{
838 Specify TCP/IP service port
839 T}
840 auth[enticate]  -A      T{
841 Set preauthentication type (default `password')
842 T}
843 timeout         -t      T{
844 Server inactivity timout in seconds (default 300)
845 T}
846 envelope        -E      T{
847 Specify envelope-address header name
848 T}
849 no envelope     \&      T{
850 Disable looking for envelope address
851 T}
852 qvirtual        -Q      T{
853 Qmail virtual domain prefix to remove from user name
854 T}
855 aka             \&      T{
856 Specify alternate DNS names of mailserver
857 T}
858 interface       -I      T{
859 specify IP interface(s) that must be up for server poll to take place
860 T}
861 monitor         -M      T{
862 Specify IP address to monitor for activity
863 T}
864 dns             \&      T{
865 Enable DNS lookup for multidrop (default)
866 T}
867 no dns          \&      T{
868 Disable DNS lookup for multidrop
869 T}
870 checkalias      \&      T{
871 Do comparison by IP address for multidrop
872 T}
873 no checkalias   \&      T{
874 Do comparison by name for multidrop (default)
875 T}
876 uidl            -U      T{
877 Force POP3 to use client-side UIDLs
878 T}
879 no uidl         \&      T{
880 Turn off POP3 use of client-side UIDLs (default)
881 T}
882 .TE
883
884 Here are the legal user options:
885
886 .TS
887 l l lw34.
888 Keyword         Opt     Function
889 _
890 user[name]      -u      T{
891 Set remote user name 
892 (local user name if name followed by `here') 
893 T}
894 is              \&      T{
895 Connect local and remote user names
896 T}
897 to              \&      T{
898 Connect local and remote user names
899 T}
900 pass[word]      \&      T{
901 Specify remote account password
902 T}
903 folder          -r      T{
904 Specify remote folder to query
905 T}
906 smtphost        -S      T{
907 Specify smtp host(s) to forward to
908 T}
909 smtpaddress     -D      T{
910 Specify the domain to be put in RCPT TO lines
911 T}
912 antispam        -Z      T{
913 Specify what SMTP return is interpreted as a spam-policy block
914 T}
915 mda             -m      T{
916 Specify MDA for local delivery
917 T}
918 preconnect      \&      T{
919 Command to be executed before each connection
920 T}
921 postconnect     \&      T{
922 Command to be executed after each connection
923 T}
924 keep            -k      T{
925 Don't delete seen messages from server
926 T}
927 flush           -F      T{
928 Flush all seen messages before querying
929 T}
930 fetchall        -a      T{
931 Fetch all messages whether seen or not
932 T}
933 rewrite         \&      T{
934 Rewrite destination addresses for reply (default)
935 T}
936 stripcr         \&      T{
937 Strip carriage returns from ends of lines
938 T}
939 forcecr         \&      T{
940 Force carriage returns at ends of lines
941 T}
942 pass8bits       \&      T{
943 Force BODY=8BITMIME to ESMTP listener
944 T}
945 dropstatus      \&      T{
946 Strip Status and X-Mozilla-Status lines out of incoming mail
947 T}
948 mimedecode      \&      T{
949 Convert quoted-printable to 8-bit in MIME messages
950 T}
951 no keep         -K      T{
952 Delete seen messages from server (default)
953 T}
954 no flush        \&      T{
955 Don't flush all seen messages before querying (default)
956 T}
957 no fetchall     \&      T{
958 Retrieve only new messages (default)
959 T}
960 no rewrite      \&      T{
961 Don't rewrite headers
962 T}
963 no stripcr      \&      T{
964 Don't strip carriage returns (default)
965 T}
966 no forcecr      \&      T{
967 Don't force carriage returns at EOL (default)
968 T}
969 no pass8bits    \&      T{
970 Don't force BODY=8BITMIME to ESMTP listener (default)
971 T}
972 no dropstatus   \&      T{
973 Don't drop Status headers (default)
974 T}
975 no mimedecode   \&      T{
976 Don't convert quoted-printable to 8-bit in MIME messages (default)
977 T}
978 limit           -l      T{
979 Set message size limit
980 T}
981 batchlimit      -b      T{
982 Max # messages to fetch in single connect
983 T}
984 fetchlimit      -B      T{
985 Max # messages to forward in single connect
986 T}
987 expunge         -e      T{
988 Perform an expunge on every #th message (IMAP only)
989 T}
990 syslog          \&      T{
991 Do error logging through syslog(3).
992 T}
993 .TE
994 .PP
995 Remember that all user options must \fIfollow\fR all server options.
996 .PP
997 In the .fetchmailrc file, the `envelope' string argument may be
998 preceded by a whitespace-separated number.  This number, if specified,
999 is the number of such headers to skip (that is, an argument of 1
1000 selects the second header of the given type).  This is sometime useful
1001 for ignoring bogus Received headers created by an ISP's local delivery
1002 agent.
1003 .SS Keywords Not Corresponding To Option Switches
1004 .PP
1005 The `folder' and `smtphost' options (unlike their command-line
1006 equivalents) can take a space- or comma-separated list of names
1007 following them.
1008 .PP
1009 All options correspond to the obvious command-line arguments, except
1010 the following: `via', `interval', `aka', `is', `to', `dns'/`no dns',
1011 `checkalias'/`no checkalias', 
1012 \&`password', \&`preconnect', \&`postconnect', `localdomains',
1013 \&`stripcr'/`no stripcr', \&`forcecr'/`no forcecr', `pass8bits'/`no
1014 pass8bits' `dropstatus/no dropstatus', `mimedecode/no mimedecode',
1015 and `no envelope'.
1016 .PP
1017 The `via' option is for use with ssh, or if you want to have more
1018 than one configuration pointing at the same site.  If it is present,
1019 the string argument will be taken as the actual DNS name of the 
1020 mailserver host to query.
1021 This will override the argument of poll, which can then simply be a
1022 distinct label for the configuration (e.g. what you would give on the
1023 command line to explicitly query this host).
1024 If the `via' name is `localhost', the poll name will also still be
1025 used as a possible match in multidrop mode; otherwise the `via' name
1026 will be used instead and the poll name will be purely a label.
1027 .PP
1028 The `interval' option (which takes a numeric argument) allows you to poll a
1029 server less frequently than the basic poll interval.  If you say
1030 \&`interval N' the server this option is attached to will only be
1031 queried every N poll intervals. 
1032 .PP
1033 The `is' or `to' keywords associate the following local (client)
1034 name(s) (or server-name to client-name mappings separated by =) with
1035 the mailserver user name in the entry.  If an is/to list has `*' as
1036 its last name, unrecognized names are simply passed through.
1037 .PP
1038 A single local name can be used to support redirecting your mail when
1039 your username on the client machine is different from your name on the
1040 mailserver.  When there is only a single local name, mail is forwarded
1041 to that local username regardless of the message's Received, To, Cc,
1042 and Bcc headers.  In this case 
1043 .I fetchmail
1044 never does DNS lookups.
1045 .PP
1046 When there is more than one local name (or name mapping) the
1047 \fIfetchmail\fR code does look at the Received, To, Cc, and Bcc
1048 headers of retrieved mail (this is `multidrop mode').  It looks for
1049 addresses with hostname parts that match your poll name or your `via',
1050 `aka' or `localdomains' options, and usually also for hostname parts
1051 which DNS tells it are aliases of the mailserver.  See the discussion
1052 of `dns', `checkalias', `localdomains', and `aka' for details on how matching
1053 addresses are handled.  If \fIfetchmail\fR cannot match any mailserver
1054 usernames or localdomain addresses, the default recipient is the
1055 calling user (as set by the USER or LOGNAME variable in the
1056 environment; you could use this to redirect to an alias like postmaster).
1057 .PP
1058 The `dns' option (normally on) controls the way addresses from
1059 multidrop mailboxes are checked.  On, it enables logic to check each
1060 host address that doesn't match an `aka' or `localdomains' declaration
1061 by looking it up with DNS.  When a mailserver username is recognized
1062 attached to a matching hostname part, its local mapping is added to
1063 the list of local recipients.
1064 .PP
1065 The `checkalias' option (normally off) extends the lookups performed
1066 by the `dns' keyword in multidrop mode, providing a way to cope with
1067 remote MTAs that identify themselves using their canonical name, while
1068 they're polled using an alias.
1069 When such a server is polled, checks to extract the envelope address
1070 fail, and
1071 .IR fetchmail 
1072 reverts to delivery using the To/Cc/Bcc headers (See below 
1073 `Header vs. Envelope addresses'). 
1074 Specifying this option instructs
1075 .IR fetchmail 
1076 to retrieve all the IP addresses associated with both the poll name
1077 and the name used by the remote MTA and to do a comparison of the IP
1078 addresses.  This comes in handy in situations where the remote server
1079 undergoes frequent canonical name changes, that would otherwise
1080 require modifications to the rcfile.  `checkalias' has no effect if
1081 `no dns' is specified in the rcfile.
1082 .PP
1083 The `aka' option is for use with multidrop mailboxes.  It allows you
1084 to pre-declare a list of DNS aliases for a server.  This is an
1085 optimization hack that allows you to trade space for speed.  When
1086 .IR fetchmail ,
1087 while processing a multidrop mailbox, grovels through message headers
1088 looking for names of the mailserver, pre-declaring common ones can
1089 save it from having to do DNS lookups.
1090 .PP
1091 The `localdomains' option allows you to declare a list of domains
1092 which fetchmail should consider local.  When fetchmail is parsing
1093 address lines in multidrop modes, and a trailing segment of a host
1094 name matches a declared local domain, that address is passed through
1095 to the listener or MDA unaltered (local-name mappings are \fInot\fR
1096 applied).
1097 .PP
1098 If you are using `localdomains', you may also need to specify \&`no
1099 envelope', which disables \fIfetchmail\fR's normal attempt to deduce
1100 an envelope address from the Received line or X-Envelope-To header or
1101 whatever header has been previously set by `envelope'.  If you set `no
1102 envelope' in the defaults entry it is possible to undo that in
1103 individual entries by using `envelope <string>'.  As a special case,
1104 \&`envelope "Received"' restores the default parsing of
1105 Received lines.
1106 .PP
1107 The \fBpassword\fR option requires a string argument, which is the password
1108 to be used with the entry's server.
1109 .PP
1110 The `preconnect' keyword allows you to specify a shell command to be
1111 executed just before each time
1112 .I fetchmail
1113 establishes a mailserver connection.  This may be useful if you are 
1114 attempting to set up secure POP connections with the aid of
1115 .IR ssh (1).
1116 If the command returns a nonzero status, the poll of that mailserver
1117 will be aborted.
1118 .PP
1119 Similarly, the `postconnect' keyword similarly allows you to specify a
1120 shell command to be executed just after each time a mailserver
1121 connection is taken down.
1122 .PP
1123 The `forcecr' option controls whether lines terminated by LF only are
1124 given CRLF termination before forwarding.  Strictly speaking RFC821
1125 requires this, but few MTAs enforce the requirement it so this option
1126 is normally off (only one such MTA, qmail, is in significant use at
1127 time of writing).  
1128 .PP
1129 The `stripcr' option controls whether carriage returns are stripped
1130 out of retrieved mail before it is forwarded.  It is normally not
1131 necessary to set this, because it defaults to `on' (CR stripping
1132 enabled) when there is an MDA declared but `off' (CR stripping
1133 disabled) when forwarding is via SMTP.  If `stripcr' and `forcecr' are
1134 both on, `stripcr' will override.
1135 .PP
1136 The `pass8bits' option exists to cope with Microsoft mail programs that
1137 stupidly slap a "Content-Transfer-Encoding: 7bit" on everything.  With
1138 this option off (the default) and such a header present, 
1139 .I fetchmail
1140 declares BODY=7BIT to an ESMTP-capable listener; this causes problems for
1141 messages actually using 8-bit ISO or KOI-8 character sets, which will
1142 be garbled by having the high bits of all characters stripped.  If
1143 \&`pass8bits' is on, 
1144 .I fetchmail
1145 is forced to declare BODY=8BITMIME to any ESMTP-capable listener.  If
1146 the listener is 8-bit-clean (as all the major ones now are) the right
1147 thing will probably result.
1148 .PP
1149 The `dropstatus' option controls whether nonempty Status and
1150 X-Mozilla-Status lines are retained in fetched mail (the default) or
1151 discarded.  Retaining them allows your MUA to see what messages (if
1152 any) were marked seen on the server.  On the other hand, it can
1153 confuse some new-mail notifiers, which assume that anything with a
1154 Status line in it has been seen.  (Note: the empty Status lines
1155 inserted by some buggy POP servers are unconditionally discarded.)
1156 .PP
1157 The `mimedecode' option controls whether MIME messages using the
1158 quoted-printable encoding are automatically converted into pure
1159 8-bit data. If you are delivering mail to an ESMTP-capable,
1160 8-bit-clean listener (that includes all of the major programs
1161 like sendmail), then this will automatically convert quoted-printable
1162 message headers and data into 8-bit data, making it easier to
1163 understand when reading mail. If your e-mail programs know how to
1164 deal with MIME messages, then this option is not needed.
1165 .PP
1166 .SS Miscellaneous Run Control Options
1167 The words `here' and `there' have useful English-like
1168 significance.  Normally `user eric is esr' would mean that 
1169 mail for the remote user `eric' is to be delivered to `esr',
1170 but you can make this clearer by saying `user eric there is esr here',
1171 or reverse it by saying `user esr here is eric there'
1172 .PP
1173 Legal protocol identifiers for use with the `protocol' keyword are:
1174
1175     auto (or AUTO)
1176     pop2 (or POP2)
1177     pop3 (or POP3)
1178     imap (or IMAP)
1179     imap-k4 (or IMAP-K4)
1180     imap-gss (or IMAP-GSS)
1181     apop (or APOP)
1182     kpop (or KPOP)
1183
1184 .PP
1185 Legal authentication types are `password' or `kerberos'.  The former
1186 specifies authentication by normal transmission of a password (the
1187 password may be plaintext or subject to protocol-specific encryption
1188 as in APOP); the second tells \fIfetchmail\fR to try to get a Kerberos
1189 ticket at the start of each query instead, and send an arbitrary
1190 string as the password.
1191 .PP
1192 Specifying `kpop' sets POP3 protocol over port 1109 with Kerberos V4
1193 preauthentication.  These defaults may be overridden by later options.
1194 .PP
1195 There are currently three global option statements; `set logfile'
1196 followed by a string sets the same global specified by --logfile.  A
1197 command-line --logfile option will override this.  Also, `set daemon'
1198 sets the poll interval as --daemon does.  This can be overridden by
1199 a command-line --daemon option; in particular --daemon 0 can be used 
1200 to force foreground operation. Finally, `set syslog' sends log
1201 messages to syslogd(8).
1202
1203 .SH INTERACTION WITH RFC 822
1204 When trying to detertmine the originating address of a message,
1205 fetchmail looks through headers in the following order: 
1206
1207         Return-Path:
1208         Resent-Sender:
1209         Sender:
1210         Resent-From:
1211         From:
1212         Reply-To:
1213         Apparently-From:
1214
1215 The originating address is used for logging, and to set the MAIL FROM
1216 address when forwarding to SMTP.  This order is intended to cope
1217 gracefully with receiving mailing list messages in multidrop mode. The
1218 intent is that if a local address doesn't exist, the bounce message
1219 won't be returned blindly to the author or to the list itself, but
1220 rather to the list manager (which is less annoying).
1221
1222 In multidrop mode, destination headers are processed as follows:
1223 First, fetchmail looks for the Received: header (or whichever one is
1224 specified by the `envelope' option) to determine the local
1225 recipient adress. If the mail is addressed to more than one recipient,
1226 the Received line won't contain any information regarding recipient adresses.
1227
1228 Then fetchmail looks for the Resent-To:, Resent-Cc:, and Resent-Bcc:
1229 lines.  If they exists, they should contain the final recipients and
1230 have precedence over their To:/Cc:/Bcc: counterparts.  If the Resent-*
1231 lines doesn't exist, the To:, Cc:, Bcc: and Apparently-To: lines are
1232 looked for. (The presence of a Resent-To: is taken to impluy that the
1233 person referred by the To: address has already received the original
1234 copy of the mail).
1235
1236 .SH CONFIGURATION EXAMPLES
1237 Basic format is:
1238
1239 .nf
1240   poll SERVERNAME protocol PROTOCOL username NAME password PASSWORD 
1241 .fi
1242 .PP
1243 Example:
1244
1245 .nf
1246   poll pop.provider.net protocol pop3 username jsmith password secret1
1247 .fi
1248 .PP
1249 Or, using some abbreviations:
1250
1251 .nf
1252   poll pop.provider.net proto pop3 user jsmith password secret1
1253 .fi
1254 .PP
1255 Multiple servers may be listed:
1256
1257 .nf
1258   poll pop.provider.net proto pop3 user jsmith pass secret1
1259   poll other.provider.net proto pop2 user John.Smith pass My^Hat
1260 .fi
1261
1262 Here's a version of those two with more whitespace and some noise words: 
1263
1264 .nf
1265   poll pop.provider.net proto pop3
1266       user jsmith, with password secret1, is jsmith here;
1267   poll other.provider.net proto pop2:
1268       user John.Smith, with password My^Hat, is John.Smith here;
1269 .fi
1270
1271 This version is much easier to read and doesn't cost significantly
1272 more (parsing is done only once, at startup time).
1273
1274 .PP
1275 If you need to include whitespace in a parameter string, enclose the
1276 string in double quotes.  Thus:
1277
1278 .nf
1279   poll mail.provider.net with proto pop3:
1280         user jsmith there has password "u can't krak this"
1281                     is jws here and wants mda "/bin/mail"
1282 .fi
1283
1284 You may have an initial server description headed by the keyword
1285 `defaults' instead of `poll' followed by a name.  Such a record
1286 is interpreted as defaults for all queries to use. It may be overwritten
1287 by individual server descriptions.  So, you could write:
1288
1289 .nf
1290   defaults proto pop3
1291         user jsmith
1292   poll pop.provider.net
1293         pass secret1
1294   poll mail.provider.net
1295         user jjsmith there has password secret2
1296 .fi
1297
1298 It's possible to specify more than one user per server (this is only
1299 likely to be useful when running fetchmail in daemon mode as root).
1300 The `user' keyword leads off a user description, and every user specification
1301 in a multi-user entry must include it.  Here's an example:
1302
1303 .nf
1304   poll pop.provider.net proto pop3 port 3111
1305         user jsmith with pass secret1 is smith here
1306         user jones with pass secret2 is jjones here
1307 .fi
1308
1309 This associates the local username `smith' with the pop.provider.net
1310 username `jsmith' and the local username `jjones' with the
1311 pop.provider.net username `jones'.
1312 .PP
1313 Here's what a simple retrieval configuration for a multi-drop mailbox
1314 looks like:
1315
1316 .nf
1317   poll pop.provider.net:
1318         user maildrop with pass secret1 to golux hurkle=happy snark here
1319 .fi
1320
1321 This says that the mailbox of account `maildrop' on the server is a
1322 multi-drop box, and that messages in it should be parsed for the
1323 server user names `golux', `hurkle', and `snark'.  It further
1324 specifies that `golux' and `snark' have the same name on the
1325 client as on the server, but mail for server user `hurkle' should be
1326 delivered to client user `happy'.
1327 .PP
1328 Here's an example of another kind of multidrop connection:
1329
1330 .nf
1331   poll pop.provider.net localdomains loonytoons.org:
1332         user maildrop with pass secret1 to esr * here
1333 .fi
1334
1335 This also says that the mailbox of account `maildrop' on the server is
1336 a multi-drop box.  It tells fetchmail that any address in the
1337 loonytoons.org domain (including subdomain addresses like
1338 `joe@daffy.loonytoons.org') should be passed through to the local SMTP
1339 listener without modification.  Be careful of mail loops if you do this!
1340 .PP
1341 Here's an example configuration using ssh.  The queries go through an
1342 ssh connecting local port 1234 to port 110 on mailhost.net; the
1343 preconnect command sets up the ssh.
1344
1345 .nf
1346 poll mailhost.net via localhost port 1234 with proto pop3:
1347         preconnect "ssh -f -L 1234:mailhost.net:110
1348                 mailhost.net sleep 20 </dev/null >/dev/null";
1349 .fi
1350
1351 .SH THE USE AND ABUSE OF MULTIDROP MAILBOXES
1352 Use the multiple-local-recipients feature with caution -- it can bite.
1353 Also note that all multidrop features are ineffective in ETRN mode.
1354
1355 .SS Header vs. Envelope addresses 
1356 The fundamental problem is that by having your mailserver toss several
1357 peoples' mail in a single maildrop box, you may have thrown away
1358 potentially vital information about who each piece of mail was
1359 actually addressed to (the `envelope address', as opposed to the
1360 header addresses in the RFC822 To/Cc/Bcc headers).  This `envelope
1361 address' is the address you need in order to reroute mail properly.
1362 .PP
1363 Sometimes 
1364 .I fetchmail
1365 can deduce the envelope address.  If the mailserver MTA is
1366 .I sendmail
1367 and the item of mail had just one recipient, the MTA will have written
1368 a `by/for' clause that gives the envelope addressee into its Received
1369 header. But this doesn't work reliably for other MTAs, nor if there is
1370 more than one recipient.  By default, \fIfetchmail\fR looks for
1371 envelope addresses in these lines; you can restore this default with
1372 -E "Received" or \&`envelope Received'.
1373 .PP
1374 Alternatively, some SMTP listeners and/or mail servers insert a header
1375 in each message containing a copy of the envelope addresses.  This
1376 header (when it exists) is often `X-Envelope-To'.  Fetchmail's
1377 assumption about this can be changed with the -E or `envelope' option.
1378 Note that writing an envelope header of this kind exposes the names of
1379 recipients (including blind-copy recopients) to all receivers of the
1380 messages; it is therefore regarded by some administrators as a
1381 security/privacy problem.
1382 .PP
1383 A slight variation of the `X-Envelope-To' header is the `Delivered-To' put
1384 by qmail to avoid mail loops. It will probably prefix the user name with a
1385 string that normally matches the user's domain. To remove this prefix you
1386 can use the -Q or `qvirtual' option.
1387 .PP
1388 Sometimes, unfortunately, neither of these methods works.  When they
1389 all fail, fetchmail must fall back on the contents of To/Cc/Bcc
1390 headers to try to determine recipient addressees -- and these are not
1391 reliable.  In particular, mailing-list software often ships mail with
1392 only the list broadcast address in the To header.
1393 .PP
1394 When
1395 .I fetchmail
1396 cannot deduce a recipient address that is local, and the intended
1397 recipient address was anyone other than fetchmail's invoking user,
1398 mail will get lost.  This is what makes the multidrop feature risky.
1399 .PP
1400 A related problem is that when you blind-copy a mail message, the Bcc
1401 information is carried \fIonly\fR as envelope address (it's not put
1402 in the headers fetchmail can see unless there is an X-Envelope
1403 header).  Thus, blind-copying to someone who gets mail over a
1404 fetchmail link will fail unless the the mailserver host routinely
1405 writes X-Envelope or an equivalent header into messages in your maildrop.
1406
1407 .SS Good Ways To Use Multidrop Mailboxes
1408 Multiple local names can be used to administer a mailing list from the
1409 client side of a \fIfetchmail\fR collection.  Suppose your name is
1410 \&`esr', and you want to both pick up your own mail and maintain a mailing
1411 list called (say) "fetchmail-friends", and you want to keep the alias
1412 list on your client machine.
1413 .PP
1414 On your server, you can alias \&`fetchmail-friends' to `esr'; then, in
1415 your \fI.fetchmailrc\fR, declare \&`to esr fetchmail-friends here'.
1416 Then, when mail including `fetchmail-friends' as a local address
1417 gets fetched, the list name will be appended to the list of
1418 recipients your SMTP listener sees.  Therefore it will undergo alias
1419 expansion locally.  Be sure to include `esr' in the local alias
1420 expansion of fetchmail-friends, or you'll never see mail sent only to
1421 the list.  Also be sure that your listener has the "me-too" option set
1422 (sendmail's -oXm command-line option or OXm declaration) so your name
1423 isn't removed from alias expansions in messages you send.
1424 .PP
1425 This trick is not without its problems, however.  You'll begin to see
1426 this when a message comes in that is addressed only to a mailing list
1427 you do \fInot\fR have declared as a local name.  Each such message
1428 will feature an `X-Fetchmail-Warning' header which is generated
1429 because fetchmail cannot find a valid local name in the recipient
1430 addresses.  Such messages default (as was described above) to being
1431 sent to the local user running
1432 .IR fetchmail ,
1433 but the program has no way to know that that's actually the right thing.
1434
1435 .SS Bad Ways To Abuse Multidrop Mailboxes
1436 Multidrop mailboxes and 
1437 .I fetchmail
1438 serving multiple users in daemon mode do not mix.  The problem, again, is
1439 mail from mailing lists, which typically does not have an individual
1440 recipient address on it.   Unless 
1441 .I fetchmail
1442 can deduce an envelope address, such mail will only go to the account
1443 running fetchmail (probably root).  Also, blind-copied users are very
1444 likely never to see their mail at all.
1445 .PP
1446 If you're tempted to use 
1447 .I fetchmail 
1448 to retrieve mail for multiple users from a single mail drop via POP or
1449 IMAP, think again (and reread the section on header and envelope
1450 addresses above).  It would be smarter to just let the mail sit in the
1451 mailserver's queue and use fetchmail's ETRN mode to trigger SMTP sends
1452 periodically (of course, this means you have to poll more frequently
1453 than the mailserver's expiry period).  If you can't arrange this, try
1454 setting up a UUCP feed.
1455 .PP
1456 If you absolutely \fImust\fR use multidrop for this purpose, make sure
1457 your mailserver writes an envelope-address header that fetchmail can
1458 see.  Otherwise you \fIwill\fR lose mail and it \fIwill\fR come back
1459 to haunt you.
1460
1461 .SS Speeding Up Multidrop Checking
1462 Normally, when multiple user are declared 
1463 .I fetchmail
1464 extracts recipient addresses as described above and checks each host
1465 part with DNS to see if it's an alias of the mailserver.  If so, the
1466 name mappings described in the to ... here declaration are done and
1467 the mail locally delivered.
1468 .PP
1469 This is the safest but also slowest method.  To speed it up,
1470 pre-declare mailserver aliases with `aka'; these are checked before
1471 DNS lookups are done.  If you're certain your aka list contains
1472 .B all
1473 DNS aliases of the mailserver (and all MX names pointing at it) 
1474 you can declare `no dns' to suppress DNS lookups entirely and
1475 \fIonly\fR match against the aka list.
1476
1477 .SH EXIT CODES
1478 To facilitate the use of 
1479 .I fetchmail
1480 in shell scripts, an exit code is returned to give an indication
1481 of what occurred during a given connection.
1482 .PP
1483 The exit codes returned by 
1484 .I fetchmail
1485 are as follows:
1486 .IP 0
1487 One or more messages were successfully retrieved.
1488 .IP 1
1489 There was no mail awaiting retrieval.  (There may have been old mail still
1490 on the server but not selected for retrieval.)
1491 .IP 2
1492 An error was encountered when attempting to open a socket for the POP 
1493 connection.  If you don't know what a socket is, don't worry about it --
1494 just treat this as an 'unrecoverable error'.
1495 .IP 3
1496 The user authentication step failed.  This usually means that a bad 
1497 user-id, password, or APOP id was specified.
1498 .IP 4
1499 Some sort of fatal protocol error was detected.
1500 .IP 5
1501 There was a syntax error in the arguments to 
1502 .I fetchmail.
1503 .IP 6
1504 The run control file had bad permissions.
1505 .IP 7
1506 There was an error condition reported by the server.  Can also
1507 fire if
1508 .I fetchmail
1509 timed out while waiting for the server.
1510 .IP 8
1511 Client-side exclusion error.  This means 
1512 .I fetchmail
1513 either found another copy of itself already running, or failed in such
1514 a way that it isn't sure whether another copy is running.
1515 .IP 9
1516 The user authentication step failed because the server responded "lock
1517 busy".  Try again after a brief pause!  This error is not implemented
1518 for all protocols, nor for all servers.  If not implemented for your
1519 server, "3" will be returned instead, see above.  May be returned when
1520 talking to qpopper or other servers that can respond with "lock busy"
1521 or some similar text containing the word "lock".
1522 .IP 10
1523 The 
1524 .I fetchmail.
1525 run failed while trying to do an SMTP port open or transaction.
1526 .IP 11
1527 Fatal DNS error.  Fetchmail encountered an error while performing
1528 a DNS lookup at startup and could not proceed.
1529 .IP 11
1530 Internal error.  You should see a message on standard error with
1531 details.
1532 .PP
1533 When
1534 .I fetchmail
1535 queries more than one host, return status is 0 if \fIany\fR query
1536 successfully retrieved mail. Otherwise the returned error status is
1537 that of the last host queried.
1538
1539 .SH AUTHOR
1540 Eric S. Raymond <esr@snark.thyrsus.com>.  
1541 This program is descended from and replaces 
1542 .IR popclient , 
1543 by Carl Harris <ceharris@mal.com>; the internals are quite different, 
1544 but some of its interface design is directly traceable to that
1545 ancestral program.
1546
1547 .SH FILES
1548 .TP 5
1549 ~/.fetchmailrc
1550 default run control file
1551 .TP 5
1552 ~/.fetchids
1553 default location of file associating hosts with last message IDs seen
1554 (used only with newer RFC1725-compliant POP3 servers supporting the
1555 UIDL command).
1556 .TP 5
1557 ~/.netrc 
1558 your FTP run control file, which (if present) will be searched for
1559 passwords as a last resort before prompting for one interactively.
1560 .TP 5
1561 ~/.fetchmail.pid
1562 lock file to help prevent concurrent runs (non-root mode).
1563 .TP 5
1564 /var/run/fetchmail.pid
1565 lock file to help prevent concurrent runs (root mode, Linux systems).
1566 .TP 5
1567 /etc/fetchmail.pid
1568 lock file to help prevent concurrent runs (root mode, systems without /var/run).
1569
1570 .SH ENVIRONMENT
1571 For correct initialization, 
1572 .I fetchmail
1573 requires either that both the USER and HOME environment variables are
1574 correctly set, or that \fBgetpwuid\fR(3) be able to retrieve a password
1575 entry from your user ID.
1576
1577 .SH SIGNALS
1578 If a
1579 .I fetchmail
1580 daemon is running as root, SIGHUP wakes it up from its sleep phase and
1581 forces a poll of all non-skipped servers (this is in accordance with
1582 the usual conventions for system daemons).
1583 .PP
1584 If
1585 .I fetchmail
1586 is running in daemon mode as non-root, use SIGUSR1 to wake it (this is
1587 so SIGHUP due to logout can retain the default action of killing it).
1588 .PP
1589 Running
1590 .I fetchmail
1591 in foreground while a background fetchmail is running will do
1592 whichever of these is appropriate to wake it up.
1593
1594 .SH BUGS AND KNOWN PROBLEMS
1595 Enabling the `mimedecode' option (which defaults to off) may render
1596 invalid any PGP signatures attached to mail with quoted-printable headers.
1597 This bug will be fixed in a future version.
1598 .P
1599 The RFC822 address parser used in multidrop mode chokes on some
1600 @-addresses that are technically legal but bizarre.  Strange uses of
1601 quoting and embedded comments are likely to confuse it.
1602 .PP
1603 Use of any of the supported protocols other than POP3 with OTP or RPA, APOP,
1604 KPOP, IMAP-K4, IMAP-GSS, or ETRN requires that the program send unencrypted
1605 passwords over the TCP/IP connection to the mailserver.  This creates
1606 a risk that name/password pairs might be snaffled with a packet
1607 sniffer or more sophisticated monitoring software.  Under Linux, the
1608 --interface option can be used to restrict polling to availability of
1609 a specific interface device with a specific local IP address, but
1610 snooping is still possible if (a) either host has a network device
1611 that can be opened in promiscuous mode, or (b) the intervening network
1612 link can be tapped.
1613 .PP
1614 Use of the %F or %T escapes in an mda option could open a security
1615 hole, because they pass text manipulable by an attacker to a shell
1616 command.  Potential shell characters are replaced by `_' before
1617 execution.  The hole is further reduced by the fact that fetchmail
1618 temporarily discards any suid privileges it may have while running the
1619 MDA.  For maximum safety, however, don't use an mda command containing
1620 %F or %T when fetchmail is run from the root account itself.
1621 .PP
1622 Send comments, bug reports, gripes, and the like to Eric S. Raymond
1623 <esr@thyrsus.com>.  An HTML FAQ is available at the fetchmail home
1624 page; surf to http://www.tuxedo.org/~esr/fetchmail or do a WWW search
1625 for pages with `fetchmail' in their titles.
1626
1627 .SH SEE ALSO
1628 elm(1), mail(1), sendmail(8), popd(8), imapd(8)
1629 .SH APPLICABLE STANDARDS
1630 .TP 5
1631 SMTP/ESMTP:
1632 RFC 821, RFC 1869, RFC 1652, RFC 1870, RFC1983, RFC 1985
1633 .TP 5
1634 mail:
1635 RFC 822
1636 .TP 5
1637 POP2:
1638 RFC 937
1639 .TP 5
1640 POP3:
1641 RFC 1081, RFC 1225, RFC 1460, RFC 1725, RFC 1939
1642 .TP 5
1643 APOP:
1644 RFC 1460, RFC 1725, RFC 1939
1645 .TP 5
1646 RPOP:
1647 RFC 1081, RFC 1225
1648 .TP 5
1649 IMAP2/IMAP2BIS:
1650 RFC 1176, RFC 1732
1651 .TP 5
1652 IMAP4:
1653 RFC 1730, RFC 1731, RFC 1732, RFC 2060, RFC 2061
1654 .TP 5
1655 ETRN:
1656 RFC 1985
1657 .TP 5
1658 OTP:
1659 RFC 1938