]> Pileus Git - ~andy/fetchmail/blob - fetchmail.man
a5a24d1616b0e6c03f2c2aab196dcd3d4cc6016d
[~andy/fetchmail] / fetchmail.man
1 .\" For license terms, see the file COPYING in this directory.
2 .TH fetchmail LOCAL
3 .SH NAME
4 fetchmail \- fetch mail from a POP or IMAP server
5
6 .SH SYNOPSIS
7 \fBfetchmail\fR [\fIoptions\fR] [\fImailserver...\fR]
8
9 .SH DESCRIPTION
10 .I fetchmail
11 is a mail-retrieval and forwarding utility; it fetches
12 mail from remote mailservers and forwards it to your local (client)
13 machine's delivery system.  You can then handle the retrieved mail
14 using normal mail user agents such as \fIelm\fR(1) or \fIMail\fR(1).
15 The \fBfetchmail\fR utility can be run in a daemon mode to repeatedly
16 poll one or more systems at a specified interval.
17 .PP
18 The
19 .I fetchmail
20 program can gather mail from servers supporting any of the common
21 mail-retrieval protocols: POP2 (as specified in RFC 937), POP3 (RFC
22 1939), IMAP2bis (as implemented by the 4.4BSD imapd program), and
23 IMAP4 (as specified by RFC 1730).  It can use (but does not require)
24 the LAST facility removed from later POP3 versions.
25 .PP
26 While
27 .I fetchmail
28 is primarily intended to be used over on-demand TCP/IP links (such as
29 SLIP or PPP connections), it may also be useful as a message transfer
30 agent for sites which refuse for security reasons to permit
31 (sender-initiated) SMTP transactions with sendmail.
32 .PP
33 As each message is retrieved \fIfetchmail\fR normally delivers it via SMTP to
34 port 25 on the machine it is running on (localhost), just as though it
35 were being passed in over a normal TCP/IP link.  The mail will then be
36 delivered locally via your system's MDA (Mail Delivery Agent, usually
37 \fIsendmail\fR(8) but your system may use a different one such
38 as \fIsmail\fR, \fImmdf\fR, or \fIqmail\fR).  All the delivery-control
39 mechanisms (such as \fI.forward\fR files) normally available through
40 your system MDA will therefore work.
41 .PP
42 The behavior of
43 .I fetchmail
44 is controlled by command-line options and a run control file,
45 \fI~/.fetchmailrc\fR, the syntax of which we describe below.  Command-line
46 options override
47 .I ~/.fetchmailrc
48 declarations.
49 .PP
50 Each server name that you specify following the options on the
51 command line will be queried.  If you don't specify any servers
52 on the command line, each server in your 
53 .I ~/.fetchmailrc
54 file will be queried.
55 .PP
56 To facilitate the use of
57 .I fetchmail
58 In scripts, pipelines, etc., it returns an appropriate exit code upon 
59 termination -- see EXIT CODES below.
60
61 .SH OPTIONS
62 The following options modify the behavior of \fIfetchmail\fR.  It is
63 seldom necessary to specify any of these once you have a
64 working \fI.fetchmailrc\fR file set up.
65 .PP
66 Some special options are not covered here, but are documented insttead
67 in sections on AUTHENTICATION and DAEMON MODE which follows.
68 .SS General Options
69 .TP
70 .B \-V, --version
71 Displays the version information for your copy of 
72 .I fetchmail.
73 No mail fetch is performed.
74 Instead, for each server specified, all option information
75 that would be computed if
76 .I fetchmail.
77 were connecting to that server is displayed.  Any non-printables in
78 passwords or other string names are shown as backslashed C-like
79 escape sequences.  This option is useful for verifying that your
80 options are set the way you want them.
81 .TP
82 .B \-c, --check
83 Return a status code to indicate whether there is mail waiting,
84 without actually fetching or deleting mail (see EXIT CODES below).
85 This option doesn't play well with queries to multiple sites, and
86 is ignored in daemon mode.  It's also prone to false positives if
87 you leave read but undeleted mail in your server mailbox.
88 .TP
89 .B \-s, --silent
90 Silent mode.  Suppresses all progress/status messages that are normally
91 echoed to standard error during a fetch.  The --verbose option
92 overrides this.
93 .TP
94 .B \-v, --verbose
95 Verbose mode.  All control messages passed between 
96 .I fetchmail
97 and the mailserver are echoed to stderr.  Overrides --silent.
98 .TP
99 .B \-a, --all
100 Retrieve both old (seen) and new messages from the mailserver.  The
101 default is to fetch only messages the server has not marked seen.
102 Note that POP2 retrieval behaves as though --all is always on (see
103 RETRIEVAL FAILURE MODES below).
104 .TP
105 .B \-k, --keep
106 Keep retrieved messages on the remote mailserver.  Normally, messages 
107 are deleted from the folder on the mailserver after they have been retrieved.
108 Specifying the 
109 .B keep 
110 option causes retrieved messages to remain in your folder on the mailserver.
111 .TP
112 .B \-K, --kill
113 Delete retrieved messages from the remote mailserver.  This
114 option forces retrieved mail to be deleted.  It may be useful if
115 you have specified a default of \fBnokill\fR in your \fI.fetchmailrc\fR.
116 .TP
117 .B \-F, --flush
118 POP3/IMAP only.  Delete old (previously retrieved) messages from the mailserver
119 before retrieving new messages.
120 .SS Protocol and Query Options
121 .TP
122 .B \-p, \--protocol proto
123 Specify the protocol to used when communicating with the remote 
124 mailserver.  If no protocol is specified,
125 .I fetchmail
126 will try each of the supported protocols in turn, terminating after
127 any successful attempt.
128 .I proto 
129 may be one of the following:
130 .RS
131 .IP IMAP
132 IMAP2bis, a compatible subset of IMAP4.
133 .IP POP2
134 Post Office Protocol 2
135 .IP POP3
136 Post Office Protocol 3
137 .IP APOP
138 Use POP3 with MD5 authentication.
139 .IP RPOP
140 Use POP3 with RPOP authentication.
141 .IP KPOP
142 Use POP3 with Kerberos authentication on port 1109.
143 .RE
144 .TP
145 .B \-P, --port
146 The  option permits you to specify a TCP/IP port to connect on. 
147 This option will seldom be necessary as all the supported protocols have
148 well-established default port numbers.
149 .TP
150 .B \-r folder, --remote folder
151 Causes a specified non-default mail folder on the mailserver to be retrieved.
152 The syntax of the folder name is server dependent, as is the default
153 behavior when no folder is specified.  This option is not available
154 under POP3.
155 .SS Delivery Control Options
156 .TP
157 .B \-S host, --smtphost host
158 Specify a host to forward mail to (other than localhost).
159 .TP
160 .B \-m, \--mda
161 You can force mail to be passed to an MDA directly (rather than
162 forwarded to port 25) with the -mda or -m option.  If \fIfetchmail\fR
163 is running as root, it sets its userid to that of the target user
164 while delivering mail through an MDA.  Some possible MDAs are
165 "/usr/sbin/sendmail -oem", "/usr/lib/sendmail -oem",
166 "/usr/bin/formail", and "/usr/bin/deliver".  Local delivery addresses
167 will be inserted into the MDA command wherever you place a %s.  Do
168 \fInot\fR use an MDA like
169 "sendmail -oem -t" that dispatches on the contents of To/Cc/Bcc, it
170 will create mail loops and bring the just wrath of many postmasters
171 down upon your head.
172 .SS Resource Limit Control Options
173 .TP
174 .B \-l, --limit
175 Takes a maximum octet size argument.  Messages larger than this size
176 will not be fetched, not be marked seen, and will be left on the
177 server (in foreground sessions, the progress messages will note that
178 they are "oversized").  The --all option overrides this one.  This
179 option is intended for those needing to strictly control fetch time
180 in interactive mode.  It may not be used with daemon mode,
181 as users would never receive a notification that messages were waiting.
182 .TP
183 .B -b, --batchlimit
184 Specify the maximum number of messages that will be shipped to an SMTP
185 listener before the connection is deliberately torn down and rebuilt
186 (defaults to 0, meaning no limit).  While \fBsendmail\fR(8) normally
187 initiates delivery of a message immediately after receiving the
188 message terminator, some SMTP listeners are not so prompt.  MTAs like
189 \fIqmail\fR(8) and \fIsmail\fR(8) will wait till the delivery socket is
190 shut down to deliver.  This may produce annoying delays when
191 .IR fetchmail (8)
192 is processing very large batches.  Setting the batch limit to some
193 nonzero size will prevent these delays.
194 .TP
195 .B -B, --fetchlimit
196 Limit the number of messages accepted from a given server in a single
197 poll.  By default there is no limit. 
198 .SS Authentication Options
199 .TP
200 .B \-u name, --username name
201 Specifies the user identification to be used when logging in to the mailserver.
202 The appropriate user identification is both server and user-dependent.  
203 The default is your login name on the client machine that is running 
204 .I fetchmail.
205 See USER AUTHENTICATION below for a complete description.
206 .TP
207 .B \-I specification, --interface specification
208 Require that a specific interface device be up and have a specific local
209 IP address (or range) before polling.  Frequently
210 .I fetchmail
211 is used over a transient point-to-point TCP/IP link established directly
212 to a mailserver via SLIP or PPP.  That is a relatively secure channel.
213 But when other TCP/IP routes to the mailserver exist (e.g. when the link
214 is connected to an alternate ISP), your username and password may be
215 vulnerable to snooping (especially when daemon mode automatically polls
216 for mail, shipping a clear password over the net at predictable
217 intervals).  The --interface option may be used to prevent this.  When
218 the specified link is not up or is not connected to a matching IP
219 address, polling will be skipped.  The format is:
220 .sp
221         interface/iii.iii.iii.iii/mmm.mmm.mmm.mmm
222 .sp
223 The field before the first slash is the interface name (i.e. sl0, ppp0
224 etc.).  The field before the second slash is the acceptable IP address.
225 The field after the second slash is a mask which specifies a range of
226 IP addresses to accept.  If no mask is present 255.255.255.255 is
227 assumed (i.e. an exact match).  This option is currently only supported
228 under Linux.
229 .TP
230 .B \-M interface, --monitor interface
231 Daemon mode can cause transient links which are automatically taken down
232 after a period of inactivity (e.g. PPP links) to remain up
233 indefinitely.  This option identifies a system TCP/IP interface to be
234 monitored for activity.  After each poll interval, if the link is up and
235 no other activity has occurred on the link then the poll will be
236 skipped.  This option is currently only supported under Linux.
237 .TP
238 .B \-A, --auth
239 This option permits you to specify an authentication type (see USER
240 AUTHENTICATION below for details).  The possible values are
241 \&`\fBpassword\fR' and `\fBkerberos\fR'.  This option is provided
242 primarily for developers; choosing KPOP protocol automatically selects
243 Kerberos authentication, and all other alternatives use ordinary
244 password authentication (though APOP uses a generated one-time
245 key as the password).
246 .SS Miscellaneous Options
247 .TP
248 .B \-f pathname, --fetchmailrc pathname
249 Specify a non-default name for the 
250 .I .fetchmailrc
251 run control file.
252 .TP
253 .B \-i pathname, --idfile pathname
254 Specify an alternate name for the .fetchids file used to save POP3
255 UIDs. 
256 .TP
257 .B \-n, --norewrite
258 Normally,
259 .I fetchmail
260 edits RFC-822 address headers (To, From, Cc, Bcc, and Reply-To) in
261 fetched mail so that any mail IDs local to the server are expanded to
262 full addresses (@ and the mailserver hostname are appended).  This enables 
263 replies on the client to get addressed correctly (otherwise your
264 mailer might think they should be addressed to local users on the
265 client machine!).  This option disables the rewrite.  (This option is
266 provided to pacify people who are paranoid about having an MTA edit
267 mail headers and want to know they can prevent it, but it is generally
268 not a good idea to actually turn off rewrite.)
269 .TP
270 .B -E, --envelope
271 This option changes the header 
272 .I fetchmail
273 assumes will carry a copy of the mail's envelope address.  Normally
274 this is `X-Envelope-To' but as this header is not standard, practice
275 varies. See the discussion of multidrop address handling below.
276
277 .SH USER AUTHENTICATION
278 Normal user authentication in 
279 .I fetchmail
280 is very much like the authentication mechanism of 
281 .I ftp(1).
282 The correct user-id and password depend upon the underlying security
283 system at the mailserver.  
284 .PP
285 If the mailserver is a Unix machine on which you have an ordinary user 
286 account, your regular login name and password are used with 
287 .I fetchmail.
288 If you use the same login name on both the server and the client machines,
289 you needn't worry about specifying a user-id with the 
290 .B \-u
291 option \-\- 
292 the default behavior is to use your login name on the client machine as the 
293 user-id on the server machine.  If you use a different login name
294 on the server machine, specify that login name with the
295 .B \-u
296 option.  e.g. if your login name is 'jsmith' on a machine named 'mailgrunt',
297 you would start 
298 .I fetchmail 
299 as follows:
300 .IP
301 fetchmail -u jsmith mailgrunt
302 .PP
303 The default behavior of 
304 .I fetchmail
305 is to prompt you for your mailserver password before the connection is
306 established.  This is the safest way to use 
307 .I fetchmail
308 and ensures that your password will not be compromised.  You may also specify
309 your password in your
310 .I ~/.fetchmailrc
311 file.  This is convenient when using 
312 .I fetchmail
313 in daemon mode or with scripts.
314 .PP
315 If you do not specify a password, and
316 .I fetchmail
317 cannot extract one from your
318 .I .fetchmailrc
319 file, it will look for a 
320 .I .netrc
321 file in your home directory before requesting one interactively; if an
322 entry matching the mailserver is found in that file, the password will
323 be used.  See the
324 .IR ftp (1)
325 man page for details of the syntax of the
326 .I .netrc
327 file.  (This feature may allow you to avoid duplicating password
328 information in more than one file.)
329 .PP
330 On mailservers that do not provide ordinary user accounts, your user-id and 
331 password are usually assigned by the server administrator when you apply for 
332 a mailbox on the server.  Contact your server administrator if you don't know 
333 the correct user-id and password for your mailbox account.
334 .PP
335 Early versions of POP3 (RFC1081, RFC1225) supported a crude form of
336 independent authentication using the
337 .I rhosts
338 file on the mailserver side.  Under this RPOP variant, a fixed
339 per-user ID equivalent to a password was sent in clear over a link to
340 a reserved port, with the command RPOP rather than PASS to alert the
341 server that it should do special checking.  RPOP is supported
342 by
343 .I fetchmail
344 (you can specify `protocol RPOP' to have the program send `RPOP'
345 rather than `PASS') but its use is strongly discouraged.  This
346 facility was vulnerable to spoofing and was withdrawn in RFC1460.
347 .PP
348 RFC1460 introduced APOP authentication.  In this variant of POP3,
349 you register an APOP password on your server host (the program
350 to do this with on the server is probably called \fIpopauth\fR(8)).  You
351 put the same password in your 
352 .I .fetchmailrc
353 file.  Each time 
354 .I fetchmail
355 logs in, it sends a cryptographically secure hash of your password and
356 the server greeting time to the server, which can verify it by
357 checking its authorization database. 
358 .PP
359 If your \fIfetchmail\fR was built with Kerberos support and you specify 
360 Kerberos authentication (either with --auth or the \fI.fetchmailrc\fR
361 option \fBauthenticate kerberos\fR) it will try to get a Kerberos
362 ticket from the mailserver at the start of each query. 
363
364 .SH DAEMON MODE
365 The 
366 .B --daemon
367 or
368 .B -d 
369 option runs 
370 .I fetchmail
371 in daemon mode.  You must specify a numeric argument which is a
372 polling interval in seconds.
373 .PP
374 In daemon mode, 
375 .I fetchmail
376 puts itself in background and runs forever, querying each specified
377 host and then sleeping for the given polling interval.
378 .PP
379 Simply invoking
380 .IP
381 fetchmail -d 900
382 .PP
383 will, therefore, poll all the hosts described in your 
384 .I ~/.fetchmailrc
385 file (except those explicitly excluded with the `skip' verb) once
386 every fifteen minutes.
387 .PP
388 Only one daemon process is permitted per user; in daemon mode,
389 .I fetchmail
390 makes a per-user lockfile to guarantee this.  The option
391 .B --quit
392 will kill a running daemon process.  Otherwise, calling fetchmail with
393 a daemon in the background sends a wakeup signal to the daemon,
394 forcing it to poll mailservers immediately.
395 .PP
396 The 
397 .B -t
398 or
399 .B --timeout
400 option allows you to set a server-nonresponse timeout in seconds.  If
401 a mailserver does not send a greeting message or respond to commands for
402 the given number of seconds, \fIfetchmail\fR will hang up on it.
403 Without such a timeout \fIfetchmail\fR might hang up indefinitely
404 trying to fetch mail from a down host.  This would be particularly
405 annoying for a \fIfetchmail\fR running in background.
406 .PP
407 The
408 .B -L
409 or
410 .B --logfile
411 option allows you to redirect status messages emitted while in daemon
412 mode into a specified logfile (follow the option with the logfile name).
413 The logfile is opened for append, so previous messages aren't deleted.
414 This is primarily useful for debugging configurations.
415 .PP
416 The
417 .B --syslog
418 option allows you to redirect status and error messages emitted while in
419 daemon mode to the
420 .IR syslog (3)
421 system daemon if available.
422 Messages are logged with an id of \fBfetchmail\fR, the facility \fBLOG_MAIL\fR,
423 and priorities \fBLOG_ERR\fR, \fBLOG_ALERT\fR or \fBLOG_INFO\fR.
424 This option is intended for logging status and error messages which
425 indicate the status of the daemon and the results while fetching mail
426 from the server(s).
427 Error messages for command line options and parsing the \fI.fetchmailrc\fR
428 file are still written to stderr, or the specified log file if the
429 .B -L
430 or
431 .B --logfile
432 option was used.
433 .PP
434 The \fI/etc/syslog.conf\fR file might contain the following to log
435 all messages from \fIfetchmail\fR to a single file:
436 .PP
437 .RS
438 !fetchmail
439 .br
440 *.*               /var/log/fetchmail
441 .RE
442 .PP
443 The 
444 .B \-N
445 or --nodetach option suppresses detachment of the daemon process
446 from its control terminal.  This is primarily useful for debugging.
447 .PP
448 Note that while running in daemon mode, transient errors (such as DNS
449 failures or sendmail delivery refusals) may force the fetchall
450 option on for the duration of the next polling cycle.
451 This is a robustness feature.  It means that if a message is fetched
452 (and thus marked seen by the mailserver) but not delivered locally
453 due to some transient error, it will be re-fetched during the next
454 poll cycle.
455
456 .SH RETRIEVAL FAILURE MODES
457 The protocols \fIfetchmail\fR uses to talk to mailservers are next to
458 bulletproof.  In normal operation forwarding to port 25, no message is
459 ever deleted (or even marked for deletion) on the host until the SMTP
460 listener on the client has acknowledged to \fIfetchmail\fR that the
461 message has been accepted for delivery.  When forwarding to an MDA,
462 however, there is more possibility of error (because there's no way
463 for fetchmail to get a reliable positive acknowledgement from the MDA).
464 .PP
465 The normal mode of \fIfetchmail\fR is to try to download only `new'
466 messages, leaving untouched (and undeleted) messages you have already
467 read directly on the server (or fetched with a previous \fIfetchmail
468 --keep\fR).  But you may find that messages you've already read on the
469 server are being fetched (and deleted) even when you don't specify
470 --all.  There are several reasons this can happen.
471 .PP
472 One could be that you're using POP2.  The POP2 protocol includes no
473 representation of `new' or `old' state in messages, so \fIfetchmail\fR
474 must treat all messages as new all the time.  But POP2 is obsolete, so
475 this is unlikely.
476 .PP
477 Under POP3, blame RFC1725.  That version of the POP3 protocol
478 specification removed the LAST command, and some POP servers follow it
479 (you can verify this by invoking \fIfetchmail -v\fR to the mailserver
480 and watching the response to LAST early in the query).  The
481 \fIfetchmail\fR code tries to compensate by using POP3's UID feature,
482 storing the identifiers of messages seen in each session until the
483 next session, in the \fI.fetchids\fR file.  But this doesn't track
484 messages seen with other clients, or read directly with a mailer on
485 the host but not deleted afterward.  A better solution would be to
486 switch to IMAP.
487 .PP
488 Another potential POP3 problem might be servers that insert messages
489 in the middle of mailboxes (some VMS implementations of mail are
490 rumored to do this).  The \fIfetchmail\fR code assumes that new
491 messages are appended to the end of the mailbox; when this is not true
492 it may treat some old messages as new and vice versa.  The only 
493 real fix for this problem is to  switch to IMAP.
494 .PP
495 The IMAP code uses the presence or absence of the server flag \eSeen
496 to decide whether or not a message is new.  Under Unix, it counts on
497 your IMAP server to notice the BSD-style Status flags set by mail user
498 agents and set the \eSeen flag from them when appropriate.  All Unix
499 IMAP servers we know of do this, though it's not specified by the IMAP
500 RFCs.  If you ever trip over a server that doesn't, the symptom will
501 be that messages you have already read on your host will look new to
502 the server.  In this (unlikely) case, only messages you fetched with
503 \fIfetchmail --keep\fR will be both undeleted and marked old.
504
505 .SH SPAM FILTERING
506 Newer versions of
507 .I sendmail
508 allow administrators to set up `spam filters' that block unsolicited email
509 from specified domains.  A MAIL FROM line that triggers this feature
510 will elicit an SMTP response with an error code of 571.  The
511 .I fetchmail
512 code recognizes this error and discards the message.  This is the
513 .I only
514 circumstance under which fetchmail ever discards mail.
515
516 .SH THE RUN CONTROL FILE
517 The preferred way to set up fetchmail (and the only way if you want to
518 avoid specifying passwords each time it runs) is to write a
519 \&\fI.fetchmailrc\fR file in your home directory.  To protect the security
520 of your passwords, your \fI~/.fetchmailrc\fR may not have more than
521 600 (u=rw,g=,o=) permissions;
522 .I fetchmail
523 will complain and exit otherwise.
524 .PP
525 You may read the \fI.fetchmailrc\fR file as a list of commands to 
526 be executed when 
527 .I fetchmail
528 is called with no arguments.
529 .PP
530 Comments begin with a '#' and extend through the end of the line.
531 Otherwise the file consists of a series of free-format server entries
532 or global option statement.
533 .PP
534 Any amount of whitespace separates keywords, tokens, or strings in
535 server entries, but is otherwise ignored (except that whitespace
536 enclosed in double quotes is treated as part of the string).  Keywords
537 and identifiers are case sensitive.  You may use standard C-style
538 escapes (\en, \et, \eb, octal, and hex) to embed non-printable
539 characters or string delimiters in strings.  When there is a conflict
540 between the command-line arguments and the arguments in this file, the
541 command-line arguments take precedence.
542 .PP
543 Each server entry consists of one of the keywords `poll' or `skip',
544 followed by a server name, followed by server options, followed by any
545 number of user descriptions.
546 .PP
547 The `poll' verb tells fetchmail to query this host when it is run with
548 no arguments.  The `skip' verb tells
549 .I fetchmail 
550 not to poll this host unless it is explicitly named on the command
551 line.  (The `skip' verb allows you to experiment with test entries
552 safely, or easily disable entries for hosts that are temporarily down.)
553 .PP
554 Legal server options are:
555
556     protocol (or proto)
557     port
558     authenticate (or auth)
559     timeout
560     envelope
561     aka
562     interface
563     monitor
564     dns
565     no dns
566
567 Legal user options are
568
569     username (or user)
570     is
571     to
572     password (or pass)
573     remotefolder (or remote)
574     smtphost (or smtp)
575     mda
576     preconnect
577     keep
578     flush
579     fetchall
580     rewrite
581     no keep
582     no flush
583     no fetchall
584     no rewrite
585     limit
586     fetchlimit
587     syslog
588 .PP
589 All options correspond to the obvious command-line arguments except
590 the following: `aka', `is', `to', `dns'/`no dns', `password',
591 `preconnect', and `localdomains'.
592 .PP
593 The `is' or `to' keywords associate the following local (client)
594 name(s) (or server-name to client-name mappings separated by =) with
595 the mailserver user name in the entry.  If an is/to list has `*' as
596 its last name, unrecognized names are simply passed through.
597 .PP
598 A single local name can be used to support redirecting your mail when
599 your username on the client machine is different from your name on the
600 mailserver.  When there is only a single local name, mail is forwarded
601 to that local username regardless of the message's Received, To, Cc,
602 and Bcc headers.  In this case 
603 .I fetchmail
604 never does DNS lookups.
605 .PP
606 When there is more than one local name (or name mapping) the
607 \fIfetchmail\fR code does look at the Received, To, Cc, and Bcc
608 headers of retrieved mail (this is `multidrop mode').  It looks for
609 addresses with hostname parts that match your `aka' or `localdomains'
610 options, and usually also for hostname parts which DNS tells it are
611 aliases of the mailserver.  See the discussion of `dns',
612 `localdomains', and `aka' for details on how matching addresses are
613 handled.  If \fIfetchmail\fR cannot match any mailserver usernames or
614 localdomain addresses, the default recipient is the calling user.
615 .PP
616 The `dns' option (normally on) controls the way addresses from
617 multidrop mailboxes are checked.  On, it enables logic to check each
618 host address that doesn't match an `aka' or `localdomains' declaration
619 by looking it up with DNS.  When a mailserver username is recognized
620 attached to a matching hostname part, its local mapping is added to
621 the list of local recipients.
622 .PP
623 The `aka' option is for use with multidrop mailboxes.  It allows you
624 to pre-declare a list of DNS aliases for a server.  This is an
625 optimization hack that allows you to trade space for speed.  When
626 .IR fetchmail ,
627 while processing a multidrop mailbox, grovels through message headers
628 looking for names of the mailserver, pre-declaring common ones can
629 save it from having to do DNS lookups.
630 .PP
631 The `localdomains' option allows you to declare a list of domains
632 which fetchmail should consider local.  When fetchmail is parsing
633 address lines in multidrop modes, and a trailing segment of a host
634 name matches a declared local doman, that address is passed through
635 to the listener or MDA unaltered (local-name mappings are \fInot\fR
636 applied).
637 .PP
638 The \fBpassword\fR option requires a string argument, which is the password
639 to be used with the entry's server.
640 .PP
641 The `preconnect' keyword allows you to specify a shell command to be
642 executed just before each time
643 .I fetchmail
644 establishes a mailserver connection.  This may be useful if you are 
645 attempting to set up secure POP connections with the aid of
646 .IR ssh (1).
647 .PP
648 Legal protocol identifiers are
649
650     auto (or AUTO)
651     pop2 (or POP2)
652     pop3 (or POP3)
653     imap (or IMAP)
654     apop (or APOP)
655     kpop (or KPOP)
656
657 .PP
658 Legal authentication types are `password' or `kerberos'.  The former
659 specifies authentication by normal transmission of a password (the
660 password may be plaintext or subject to protocol-specific encryption
661 as in APOP); the second tells \fIfetchmail\fR to try to get a Kerberos
662 ticket at the start of each query instead, and send an arbitrary
663 string as the password.
664 .PP
665 Specifying `kpop' sets POP3 protocol over port 1109 with Kerberos
666 authentication.  These defaults may be overridden by later options.
667 .PP
668 You can use the noise keywords `and', `with',
669 `has', `wants', and `options' anywhere in an entry to make
670 it resemble English.  They're ignored, but but can make entries much
671 easier to read at a glance.  The punctuation characters ':', ';' and
672 ',' are also ignored.
673 .PP
674 The words `here' and `there' have useful English-like
675 significance.  Normally `user eric is esr' would mean that 
676 mail for the remote user `eric' is to be delivered to `esr',
677 but you can make this clearer by saying `user eric there is esr here',
678 or reverse it by saying `user esr here is eric there'
679 .PP
680 For backward compatibility, the word `server' is a synonym for `poll'.
681 .PP
682 There is currently just one global option statement; `set logfile = '
683 followed by a string sets the same global specified by --logfile.  A
684 command-line --logfile option will override this.
685 .PP
686 Basic format is:
687
688 .nf
689   poll SERVERNAME protocol PROTOCOL username NAME password PASSWORD 
690 .fi
691 .PP
692 Example:
693
694 .nf
695   poll pop.provider.net protocol pop3 username jsmith password secret1
696 .fi
697 .PP
698 Or, using some abbreviations:
699
700 .nf
701   poll pop.provider.net proto pop3 user jsmith password secret1
702 .fi
703 .PP
704 Multiple servers may be listed:
705
706 .nf
707   poll pop.provider.net proto pop3 user jsmith pass secret1
708   poll other.provider.net proto pop2 user John.Smith pass My^Hat
709 .fi
710
711 Here's a version of those two with more whitespace and some noise words: 
712
713 .nf
714   poll pop.provider.net proto pop3
715       user jsmith, with password secret1, is jsmith here;
716   poll other.provider.net proto pop2:
717       user John.Smith, with password My^Hat, is John.Smith here;
718 .fi
719
720 This version is much easier to read and doesn't cost significantly
721 more (parsing is done only once, at startup time).
722
723 .PP
724 If you need to include whitespace in a parameter string, enclose the
725 string in double quotes.  Thus:
726
727 .nf
728   poll mail.provider.net with proto pop3:
729         user jsmith there has password "u can't krak this"
730                     is jws here and wants mda "/bin/mail"
731 .fi
732
733 You may have an initial server description headed by the keyword
734 `defaults' instead of `poll' followed by a name.  Such a record
735 is interpreted as defaults for all queries to use. It may be overwritten
736 by individual server descriptions.  So, you could write:
737
738 .nf
739   defaults proto pop3
740         user jsmith
741   poll pop.provider.net
742         pass secret1
743   poll mail.provider.net
744         user jjsmith there has password secret2
745 .fi
746
747 It's possible to specify more than one user per server (this is only
748 likely to be useful when running fetchmail in daemon mode as root).
749 The `user' keyword leads off a user description, and every user
750 description except optionally the first one must include it.  (If the
751 first description lacks the `user' keyword, the name of the
752 invoking user is used.) Here's a contrived example:
753
754 .nf
755   poll pop.provider.net proto pop3 port 3111
756         pass gumshoe
757         user jsmith with pass secret1 is smith here
758         user jones with pass secret2 is jjones here
759 .fi
760
761 This says that the user invoking \fIfetchmail\fR has the same username
762 on pop.provider.net, and password `gumshoe' there.
763 It also associates the local username `smith' with the pop.provider.net
764 username `jsmith' and the local username `jjones' with the pop.provider.net
765 username `jones'.
766 .PP
767 This example is contrived because, in practice, you are very unlikely
768 to be specifying multiple users per server unless running it as root
769 (thus the `pass gumshoe' would try to fetch root's mail on
770 pop-provider.net, which is probably not what you want).
771 In any case, we strongly recommend always having an explicit
772 \&`user' clause when specifying multiple users per mailserver.
773 .PP
774 Here's what a simple retrieval configuration for a multi-drop mailbox
775 looks like:
776
777 .nf
778   poll pop.provider.net:
779         user maildrop with pass secret1 to golux hurkle=happy snark here
780 .fi
781
782 This says that the mailbox of account `maildrop' on the server is a
783 multi-drop box, and that messages in it should be parsed for the
784 server user names `golux', `hurkle', and `snark'.  It further
785 specifies that `golux' and `snark' have the same name on the
786 client as on the server, but mail for server user `hurkle' should be
787 delivered to client user `happy'.
788 .PP
789 Here's an example of another kind of multidrop connection:
790
791 .nf
792   poll pop.provider.net localdomains loonytoons.org:
793         user maildrop with pass secret1 to esr * here
794 .fi
795
796 This also says that the mailbox of account `maildrop' on the server is
797 a multi-drop box.  It tells fetchmail that any address in the
798 loonytoons.org domain (including subdomain addresses like
799 `joe@daffy.loonytoons.org') should be passed through to the local SMTP
800 listener without modification.  Be careful of mail loops if you do this!
801
802 .SH THE USE AND ABUSE OF MULTIDROP MAILBOXES
803 Use the multiple-local-recipients feature with caution -- it can bite.
804
805 .SS Header vs. Envelope addresses 
806 The fundamental problem is that by having your mailserver toss several
807 peoples' mail in a box, you may have thrown away potentially vital
808 information about who each piece of mail was actually addressed to
809 (the `envelope address', as opposed to the addresses in the RFC822
810 To/Cc/Bcc headers).  This `envelope address' is the address you need
811 in order to reroute mail properly.
812 .PP
813 Sometimes 
814 .I fetchmail
815 can deduce the envelope address.  If the mailserver MTA is
816 .I sendmail
817 and the item of mail had just one recipient, the MTA will have written
818 a `for' clause that gives the envelope addressee into its Received
819 header. But this doesn't work reliably for other MTAs, nor if there is more
820 than one recipient.
821 .PP
822 Alternatively, some SMTP listeners and/or mail servers insert a header
823 in each message containing a copy of the envelope addresses.  This
824 header (when it exists) is often `X-Envelope-To'.  Fetchmail's
825 assumption about this can be changed with the -E or `envelope' option.
826 .PP
827 Sometimes, unfortunately, neither of these methods works.  When they
828 both fail, fetchmail must fall back on the contents of To/Cc/Bcc
829 headers to try to determine recipient addressees -- and these are not
830 reliable.  In particular, mailing-list software often ships mail with
831 the list broadcast address in the To header.
832 .PP
833 When
834 .I fetchmail
835 cannot deduce a recipient address that is local, and the intended
836 recipient address was anyone other than fetchmail's invoking user,
837 mail will get lost.  This is what makes the multidrop feature risky.
838
839 .SS Good Ways To Use Multidrop Mailboxes
840 Multiple local names can be used to administer a mailing list from the
841 client side of a \fIfetchmail\fR collection.  Suppose your name is
842 \&`esr', and you want to both pick up your own mail and maintain a mailing
843 list called (say) "fetchmail-friends", and you want to keep the alias
844 list on your client machine.
845 .PP
846 On your server, you can alias \&`fetchmail-friends' to `esr'; then, in
847 your \fI.fetchmailrc\fR, declare \&`to esr fetchmail-friends here'.
848 Then, when mail including `fetchmail-friends' as a local address
849 gets fetched, the list name will be appended to the list of
850 recipients your SMTP listener sees.  Therefore it will undergo alias
851 expansion locally.  Be sure to include `esr' in the local alias
852 expansion of fetchmail-friends, or you'll never see mail sent only to
853 the list.  Also be sure that your listener has the "me-too" option set
854 (sendmail's -oXm command-line option or OXm declaration) so your name
855 isn't removed from alias expansions in messages you send.
856 .PP
857 This trick is not without its problems, however.  You'll begin to see
858 this when a message comes in that is addressed only to a mailing list
859 you do \fInot\fR have declared as a local name.  Each such message
860 will feature an `X-Fetchmail-Warning' header which is generated
861 because fetchmail cannot find a valid local name in the recipient
862 addresses.  Such messages default (as was described above) to being
863 sent to the local user running
864 .IR fetchmail ,
865 but the program has no way to know that that's actually the right thing.
866
867 .SS Bad Ways To Abuse Multidrop Mailboxes
868 Multidrop mailboxes and 
869 .I fetchmail
870 serving multiple users in daemon mode do not mix.  The problem, again, is
871 mail from mailing lists, which typically does not have an individual
872 recipient address on it.   Unless 
873 .I fetchmail
874 can deduce an envelope address, such mail will only go to the account
875 running fetchmail (probably root).
876
877 .SS Speeding Up Multidrop Checking
878 Normally, when multiple user are declared 
879 .I fetchmail
880 extracts recipient addresses as described above and checks each host
881 part with DNS to see if it's an alias of the mailserver.  If so, the
882 name mappings described in the to ... here declaration are done and
883 the mail locally delivered.
884 .PP
885 This is the safest but also slowest method.  To speed it up,
886 pre-declare mailserver aliases with `aka'; these are checked before
887 DNS lookups are done.  If you're certain your aka list contains
888 .B all
889 DNS aliases of the mailserver (and all MX names pointing at it) 
890 you can declare `no dns' to suppress DNS lookups entirely and
891 \fIonly\fR match against the aka list.
892
893 .SH EXIT CODES
894 To facilitate the use of 
895 .I fetchmail
896 in shell scripts, an exit code is returned to give an indication
897 of what occurred during a given connection.
898 .PP
899 The exit codes returned by 
900 .I fetchmail
901 are as follows:
902 .IP 0
903 One or more messages were successfully retrieved.
904 .IP 1
905 There was no mail awaiting retrieval.
906 .IP 2
907 An error was encountered when attempting to open a socket for the POP 
908 connection.  If you don't know what a socket is, don't worry about it --
909 just treat this as an 'unrecoverable error'.
910 .IP 3
911 The user authentication step failed.  This usually means that a bad 
912 user-id, password, or APOP id was specified.
913 .IP 4
914 Some sort of fatal protocol error was detected.
915 .IP 5
916 There was a syntax error in the arguments to 
917 .I fetchmail.
918 .IP 6
919 The run control file had bad permissions.
920 .IP 7
921 There was an error condition reported by the server (POP3 only).
922 .IP 8
923 Exclusion error.  This means 
924 .I fetchmail
925 either found another copy of itself already running, or failed in such
926 a way that it isn't sure whether another copy is running.
927 .IP 9
928 The 
929 .I fetchmail.
930 run failed while trying to do an SMTP port open or transaction.
931 .IP 10
932 Internal error.  You should see a message on standard error with
933 details.
934 .PP
935 When
936 .I fetchmail
937 queries more than one host, the returned status is that of the last
938 host queried.
939
940 .SH AUTHOR
941 Eric S. Raymond <esr@snark.thyrsus.com>.  
942
943 .SH BACKWARD COMPATIBILITY
944 This program is descended from and replaces 
945 .IR popclient , 
946 by Carl Harris <ceharris@mal.com>; the internals are quite different, 
947 but some of its interface design is directly traceable to that
948 ancestral program.  Some effort has been made to preserve compatibility.
949 .PP
950 If called through a link named `popclient', \fIfetchmail\fR will look
951 in ~/.poprc for its run control file.  As long as the file does not
952 use the removed `localfolder' option or `limit' (which now takes a
953 maximum byte size rather than a line count), this will often work.
954 (The new run control file syntax also has to be a little stricter
955 about the order of options than the old, in order to support multiple
956 user desriptions per server; thus you may have to rearrange things a
957 bit.)
958
959 .SH FILES
960 .TP 5
961 ~/.fetchmailrc
962 default run control file
963 .TP 5
964 ~/.fetchids
965 default location of file associating hosts with last message IDs seen
966 (used only with newer RFC1725-compliant POP3 servers supporting the
967 UIDL command).
968 .TP 5
969 ~/.netrc your FTP run control file, which (if present) will be
970 searched for passwords as a last resort before prompting for one
971 interactively.
972 .TP 5
973 ~/.fetchmail
974 lock file to help prevent concurrent runs (non-root mode).
975 .TP 5
976 /var/run/fetchmail.pid
977 lock file to help prevent concurrent runs (root mode).
978
979 .SH ENVIRONMENT
980 For correct initialization, 
981 .I fetchmail
982 requires either that both the USER and HOME environment variables are
983 correctly set, or that \fBgetpwuid\fR(3) be able to retrieve a password
984 entry from your user ID.
985
986 .SH BUGS AND KNOWN PROBLEMS
987 Use of any of the supported protocols other than APOP or KPOP requires
988 that the program send unencrypted passwords over the TCP/IP connection
989 to the mailserver.  This creates a risk that name/password pairs
990 might be snaffled with a packet sniffer or more sophisticated
991 monitoring software.  Under Linux, the --interface option can be used
992 to restrict polling to availability of a specific interface device with
993 a specific local IP address, but snooping is still possible if (a)
994 either host has a network device that can be opened in promiscuous mode,
995 or (b) the intervening network link can be tapped.
996 .PP
997 Send comments, bug reports, gripes, and the like to Eric S. Raymond
998 <esr@thyrsus.com>.
999
1000 .SH SEE ALSO
1001 elm(1), mail(1), sendmail(8), popd(8), imapd(8)
1002 .SH APPLICABLE STANDARDS
1003 .TP 5
1004 SMTP:
1005 RFC 821
1006 .TP 5
1007 mail:
1008 RFC 822
1009 .TP 5
1010 POP2:
1011 RFC 937
1012 .TP 5
1013 POP3:
1014 RFC 1081, RFC 1225, RFC 1460, RFC 1725, RFC 1939
1015 .TP 5
1016 APOP:
1017 RFC 1460, RFC 1725, RFC 1939
1018 .TP 5
1019 RPOP:
1020 RFC 1081, RFC 1225
1021 .TP 5
1022 IMAP2/IMAP2BIS:
1023 RFC 1176, RFC 1732
1024 .TP 5
1025 IMAP4:
1026 RFC 1730, RFC 1731, RFC 1732