]> Pileus Git - ~andy/fetchmail/blob - pop3.c
c5b6d58c09ebcf552c4177752d9cdf7a76d9493b
[~andy/fetchmail] / pop3.c
1 /*
2  * pop3.c -- POP3 protocol methods
3  *
4  * Copyright 1998 by Eric S. Raymond.
5  * For license terms, see the file COPYING in this directory.
6  */
7
8 #include  "config.h"
9 #ifdef POP3_ENABLE
10 #include  <stdio.h>
11 #include  <string.h>
12 #include  <ctype.h>
13 #if defined(HAVE_UNISTD_H)
14 #include <unistd.h>
15 #endif
16 #if defined(STDC_HEADERS)
17 #include  <stdlib.h>
18 #endif
19  
20 #include  "fetchmail.h"
21 #include  "socket.h"
22 #include  "i18n.h"
23
24 #if OPIE_ENABLE
25 #include <opie.h>
26 #endif /* OPIE_ENABLE */
27
28 #ifndef strstr          /* glibc-2.1 declares this as a macro */
29 extern char *strstr();  /* needed on sysV68 R3V7.1. */
30 #endif /* strstr */
31
32 static int last;
33 #ifdef SDPS_ENABLE
34 char *sdps_envfrom;
35 char *sdps_envto;
36 #endif /* SDPS_ENABLE */
37
38 #if OPIE_ENABLE
39 static char lastok[POPBUFSIZE+1];
40 #endif /* OPIE_ENABLE */
41
42 #define DOTLINE(s)      (s[0] == '.' && (s[1]=='\r'||s[1]=='\n'||s[1]=='\0'))
43
44 int pop3_ok (int sock, char *argbuf)
45 /* parse command response */
46 {
47     int ok;
48     char buf [POPBUFSIZE+1];
49     char *bufp;
50
51     if ((ok = gen_recv(sock, buf, sizeof(buf))) == 0)
52     {
53         bufp = buf;
54         if (*bufp == '+' || *bufp == '-')
55             bufp++;
56         else
57             return(PS_PROTOCOL);
58
59         while (isalpha(*bufp))
60             bufp++;
61
62         if (*bufp)
63           *(bufp++) = '\0';
64
65         if (strcmp(buf,"+OK") == 0)
66         {
67 #if OPIE_ENABLE
68             strcpy(lastok, bufp);
69 #endif /* OPIE_ENABLE */
70             ok = 0;
71         }
72         else if (strncmp(buf,"-ERR", 4) == 0)
73         {
74             if (stage > STAGE_GETAUTH) 
75                 ok = PS_PROTOCOL;
76             /*
77              * We're checking for "lock busy", "unable to lock", 
78              * "already locked", "wait a few minutes" etc. here. 
79              * This indicates that we have to wait for the server to
80              * unwedge itself before we can poll again.
81              *
82              * PS_LOCKBUSY check empirically verified with two recent
83              * versions of the Berkeley popper; QPOP (version 2.2)  and
84              * QUALCOMM Pop server derived from UCB (version 2.1.4-R3)
85              * These are caught by the case-indifferent "lock" check.
86              * The "wait" catches "mail storage services unavailable,
87              * wait a few minutes and try again" on the InterMail server.
88              *
89              * If these aren't picked up on correctly, fetchmail will 
90              * think there is an authentication failure and wedge the
91              * connection in order to prevent futile polls.
92              *
93              * Gad, what a kluge.
94              */
95             else if (strstr(bufp,"lock")
96                      || strstr(bufp,"Lock")
97                      || strstr(bufp,"LOCK")
98                      || strstr(bufp,"wait")
99                      /* these are blessed by RFC 2449 */
100                      || strstr(bufp,"[IN-USE]")||strstr(bufp,"[LOGIN-DELAY]"))
101                 ok = PS_LOCKBUSY;
102             else
103                 ok = PS_AUTHFAIL;
104             /*
105              * We always want to pass the user lock-busy messages, because
106              * they're red flags.  Other stuff (like AUTH failures on non-
107              * RFC1734 servers) only if we're debugging.
108              */
109             if (*bufp && (ok == PS_LOCKBUSY || outlevel >= O_MONITOR))
110               report(stderr, "%s\n", bufp);
111         }
112         else
113             ok = PS_PROTOCOL;
114
115         if (argbuf != NULL)
116             strcpy(argbuf,bufp);
117     }
118
119     return(ok);
120 }
121
122 int pop3_getauth(int sock, struct query *ctl, char *greeting)
123 /* apply for connection authorization */
124 {
125     int ok;
126     char *start,*end;
127     char *msg;
128 #if OPIE_ENABLE
129     char *challenge;
130 #endif /* OPIE_ENABLE */
131
132 #ifdef SDPS_ENABLE
133     /*
134      * This needs to catch both demon.co.uk and demon.net.
135      * If we see either, and we're in multidrop mode, try to use
136      * the SDPS *ENV extension.
137      */
138     if (!(ctl->server.sdps) && MULTIDROP(ctl) && strstr(greeting, "demon."))
139         ctl->server.sdps = TRUE;
140 #endif /* SDPS_ENABLE */
141
142     switch (ctl->server.protocol) {
143     case P_POP3:
144 #ifdef RPA_ENABLE
145         /* CompuServe POP3 Servers as of 990730 want AUTH first for RPA */
146         if (strstr(ctl->remotename, "@compuserve.com"))
147         {
148             /* AUTH command should return a list of available mechanisms */
149             if (gen_transact(sock, "AUTH") == 0)
150             {
151                 char buffer[10];
152                 flag has_rpa = FALSE;
153
154                 while ((ok = gen_recv(sock, buffer, sizeof(buffer))) == 0)
155                 {
156                     if (DOTLINE(buffer))
157                         break;
158                     if (strncasecmp(buffer, "rpa", 3) == 0)
159                         has_rpa = TRUE;
160                 }
161                 if (has_rpa && !POP3_auth_rpa(ctl->remotename, 
162                                               ctl->password, sock))
163                     return(PS_SUCCESS);
164             }
165
166             return(PS_AUTHFAIL);
167         }
168 #endif /* RPA_ENABLE */
169
170         /*
171          * CAPA command may return a list including available
172          * authentication mechanisms.  if it doesn't, no harm done, we
173          * just fall back to a plain login.  Note that this code 
174          * latches the server's authentication type, so that in daemon mode
175          * the CAPA check only needs to be done once at start of run.
176          *
177          * APOP was introduced in RFC 1450, and CAPA not until
178          * RFC2449. So the < check is an easy way to prevent CAPA from
179          * being sent to the more primitive POP3 servers dating from
180          * RFC 1081 and RFC 1225, which seem more likely to choke on
181          * it.  This certainly catches IMAP-2000's POP3 gateway.
182          * 
183          * These authentication methods are blessed by RFC1734,
184          * describing the POP3 AUTHentication command.
185          */
186         if (ctl->server.authenticate == A_ANY 
187             && strchr(greeting, '<') 
188             && gen_transact(sock, "CAPA") == 0)
189         {
190 #if defined(GSSAPI)
191             flag has_gssapi = FALSE;
192 #endif /* defined(GSSAPI) */
193 #if defined(KERBEROS_V4) || defined(KERBEROS_V5)
194             flag has_kerberos = FALSE;
195 #endif /* defined(KERBEROS_V4) || defined(KERBEROS_V5) */
196             flag has_cram = FALSE;
197 #ifdef OPIE_ENABLE
198             flag has_opie = FALSE;
199 #endif /* OPIE_ENABLE */
200             char buffer[64];
201
202             /* determine what authentication methods we have available */
203             while ((ok = gen_recv(sock, buffer, sizeof(buffer))) == 0)
204             {
205                 if (DOTLINE(buffer))
206                     break;
207 #if defined(GSSAPI)
208                 if (strstr(buffer, "GSSAPI"))
209                     has_gssapi = TRUE;
210 #endif /* defined(GSSAPI) */
211 #if defined(KERBEROS_V4) || defined(KERBEROS_V5)
212                 if (strstr(buffer, "KERBEROS_V4"))
213                     has_kerberos = TRUE;
214 #endif /* defined(KERBEROS_V4) || defined(KERBEROS_V5) */
215 #ifdef OPIE_ENABLE
216                 if (strstr(buffer, "X-OTP"))
217                     has_otp = TRUE;
218 #endif /* OPIE_ENABLE */
219                 if (strstr(buffer, "CRAM-MD5"))
220                     has_cram = TRUE;
221             }
222
223             /*
224              * Here's where we set priorities.  Note that we must do tests
225              * in *reverse* order of desirability.
226              */
227             if (has_cram)
228                 ctl->server.authenticate = A_CRAM_MD5;
229 #ifdef OPIE_ENABLE
230             if (has_opie)
231                 ctl->server.authenticate = A_OTP;
232 #endif /* OPIE_ENABLE */
233 #if defined(GSSAPI)
234             if (has_gssapi)
235                 ctl->server.authenticate = A_GSSAPI;
236 #endif /* defined(GSSAPI) */
237 #if defined(KERBEROS_V4) || defined(KERBEROS_V5)
238             if (has_kerberos)
239                 ctl->server.authenticate = A_KERBEROS_V4;
240 #endif /* defined(KERBEROS_V4) || defined(KERBEROS_V5) */
241         }
242
243         /*
244          * OK, we have an authentication type now.
245          */
246 #if defined(KERBEROS_V4) || defined(KERBEROS_V5)
247         if (ctl->server.authenticate == A_KERBEROS_V4
248                 || ctl->server.authenticate == A_KERBEROS_V5)
249             return(do_rfc1731(sock, "AUTH", ctl->server.truename));
250 #endif /* defined(KERBEROS_V4) || defined(KERBEROS_V5) */
251 #if defined(GSSAPI)
252         if (ctl->server.authenticate==A_GSSAPI))
253             return(do_gssauth(sock, "AUTH", 
254                               ctl->server.truename, ctl->remotename));
255 #endif /* defined(GSSAPI) */
256 #ifdef OPIE_ENABLE
257         if (ctl->server.authenticate == A_OTP)
258             do_otp(sock, "AUTH", ctl)
259 #endif /* OPIE_ENABLE */
260         if (ctl->server.authenticate == A_CRAM_MD5)
261             return(do_cram_md5(sock, "AUTH", ctl));
262
263         /* ordinary validation, no one-time password or RPA */ 
264         gen_transact(sock, "USER %s", ctl->remotename);
265         ok = gen_transact(sock, "PASS %s", ctl->password);
266         break;
267
268     case P_APOP:
269         /* build MD5 digest from greeting timestamp + password */
270         /* find start of timestamp */
271         for (start = greeting;  *start != 0 && *start != '<';  start++)
272             continue;
273         if (*start == 0) {
274             report(stderr,
275                    _("Required APOP timestamp not found in greeting\n"));
276             return(PS_AUTHFAIL);
277         }
278
279         /* find end of timestamp */
280         for (end = start;  *end != 0  && *end != '>';  end++)
281             continue;
282         if (*end == 0 || end == start + 1) {
283             report(stderr, 
284                    _("Timestamp syntax error in greeting\n"));
285             return(PS_AUTHFAIL);
286         }
287         else
288             *++end = '\0';
289
290         /* copy timestamp and password into digestion buffer */
291         xalloca(msg, char *, (end-start+1) + strlen(ctl->password) + 1);
292         strcpy(msg,start);
293         strcat(msg,ctl->password);
294
295         strcpy(ctl->digest, MD5Digest((unsigned char *)msg));
296
297         ok = gen_transact(sock, "APOP %s %s", ctl->remotename, ctl->digest);
298         break;
299
300     case P_RPOP:
301         if ((ok = gen_transact(sock,"USER %s", ctl->remotename)) == 0)
302             ok = gen_transact(sock, "RPOP %s", ctl->password);
303         break;
304
305     default:
306         report(stderr, _("Undefined protocol request in POP3_auth\n"));
307         ok = PS_ERROR;
308     }
309
310     if (ok != 0)
311     {
312         /* maybe we detected a lock-busy condition? */
313         if (ok == PS_LOCKBUSY)
314             report(stderr, _("lock busy!  Is another session active?\n")); 
315
316         return(ok);
317     }
318
319     /*
320      * Empirical experience shows some server/OS combinations
321      * may need a brief pause even after any lockfiles on the
322      * server are released, to give the server time to finish
323      * copying back very large mailfolders from the temp-file...
324      * this is only ever an issue with extremely large mailboxes.
325      */
326     sleep(3); /* to be _really_ safe, probably need sleep(5)! */
327
328     /* we're peek-capable if use of TOP is enabled */
329     peek_capable = !(ctl->fetchall || ctl->keep);
330
331     /* we're approved */
332     return(PS_SUCCESS);
333 }
334
335 static int
336 pop3_gettopid( int sock, int num , char *id)
337 {
338     int ok;
339     int got_it;
340     char buf [POPBUFSIZE+1];
341     sprintf( buf, "TOP %d 1", num );
342     if ((ok = gen_transact(sock, buf )) != 0)
343        return ok; 
344     got_it = 0;
345     while ((ok = gen_recv(sock, buf, sizeof(buf))) == 0) 
346     {
347         if (DOTLINE(buf))
348             break;
349         if ( ! got_it && ! strncasecmp("Message-Id:", buf, 11 )) {
350             got_it = 1;
351             /* prevent stack overflows */
352             buf[IDLEN+12] = 0;
353             sscanf( buf+12, "%s", id);
354         }
355     }
356     return 0;
357 }
358
359 static int
360 pop3_slowuidl( int sock,  struct query *ctl, int *countp, int *newp)
361 {
362     /* This approach tries to get the message headers from the
363      * remote hosts and compares the message-id to the already known
364      * ones:
365      *  + if the first message containes a new id, all messages on
366      *    the server will be new
367      *  + if the first is known, try to estimate the last known message
368      *    on the server and check. If this works you know the total number
369      *    of messages to get.
370      *  + Otherwise run a binary search to determine the last known message
371      */
372     int ok, nolinear = 0;
373     int first_nr, list_len, try_id, try_nr, add_id;
374     int num;
375     char id [IDLEN+1];
376     
377     if( (ok = pop3_gettopid( sock, 1, id )) != 0 )
378         return ok;
379     
380     if( ( first_nr = str_nr_in_list(&ctl->oldsaved, id) ) == -1 ) {
381         /* the first message is unknown -> all messages are new */
382         *newp = *countp;        
383         return 0;
384     }
385
386     /* check where we expect the latest known message */
387     list_len = count_list( &ctl->oldsaved );
388     try_id = list_len  - first_nr; /* -1 + 1 */
389     if( try_id > 1 ) {
390         if( try_id <= *countp ) {
391             if( (ok = pop3_gettopid( sock, try_id, id )) != 0 )
392                 return ok;
393     
394             try_nr = str_nr_last_in_list(&ctl->oldsaved, id);
395         } else {
396             try_id = *countp+1;
397             try_nr = -1;
398         }
399         if( try_nr != list_len -1 ) {
400             /* some messages inbetween have been deleted... */
401             if( try_nr == -1 ) {
402                 nolinear = 1;
403
404                 for( add_id = 1<<30; add_id > try_id-1; add_id >>= 1 )
405                     ;
406                 for( ; add_id; add_id >>= 1 ) {
407                     if( try_nr == -1 ) {
408                         if( try_id - add_id <= 1 ) {
409                             continue;
410                         }
411                         try_id -= add_id;
412                     } else 
413                         try_id += add_id;
414                     
415                     if( (ok = pop3_gettopid( sock, try_id, id )) != 0 )
416                         return ok;
417                     try_nr = str_nr_in_list(&ctl->oldsaved, id);
418                 }
419                 if( try_nr == -1 ) {
420                     try_id--;
421                 }
422             } else {
423                 report(stderr, 
424                        _("Messages inserted into list on server. Cannot handle this.\n"));
425                 return -1;
426             }
427         } 
428     }
429     /* the first try_id messages are known -> copy them to the newsaved list */
430     for( num = first_nr; num < list_len; num++ )
431     {
432         struct idlist   *new = save_str(&ctl->newsaved, 
433                                 str_from_nr_list(&ctl->oldsaved, num),
434                                 UID_UNSEEN);
435         new->val.status.num = num - first_nr + 1;
436     }
437
438     if( nolinear ) {
439         free_str_list(&ctl->oldsaved);
440         ctl->oldsaved = 0;
441         last = try_id;
442     }
443
444     *newp = *countp - try_id;
445     return 0;
446 }
447
448 static int pop3_getrange(int sock, 
449                          struct query *ctl,
450                          const char *folder,
451                          int *countp, int *newp, int *bytes)
452 /* get range of messages to be fetched */
453 {
454     int ok;
455     char buf [POPBUFSIZE+1];
456
457     /* Ensure that the new list is properly empty */
458     ctl->newsaved = (struct idlist *)NULL;
459
460 #ifdef MBOX
461     /* Alain Knaff suggests this, but it's not RFC standard */
462     if (folder)
463         if ((ok = gen_transact(sock, "MBOX %s", folder)))
464             return ok;
465 #endif /* MBOX */
466
467     /* get the total message count */
468     gen_send(sock, "STAT");
469     ok = pop3_ok(sock, buf);
470     if (ok == 0)
471         sscanf(buf,"%d %d", countp, bytes);
472     else
473         return(ok);
474
475     /*
476      * Newer, RFC-1725-conformant POP servers may not have the LAST command.
477      * We work as hard as possible to hide this ugliness, but it makes 
478      * counting new messages intrinsically quadratic in the worst case.
479      */
480     last = 0;
481     *newp = -1;
482     if (*countp > 0 && !ctl->fetchall)
483     {
484         char id [IDLEN+1];
485
486         if (!ctl->server.uidl) {
487             gen_send(sock, "LAST");
488             ok = pop3_ok(sock, buf);
489         } else
490             ok = 1;
491         if (ok == 0)
492         {
493             if (sscanf(buf, "%d", &last) == 0)
494             {
495                 report(stderr, _("protocol error\n"));
496                 return(PS_ERROR);
497             }
498             *newp = (*countp - last);
499         }
500         else
501         {
502             /* grab the mailbox's UID list */
503             if ((ok = gen_transact(sock, "UIDL")) != 0)
504             {
505                 /* don't worry, yet! do it the slow way */
506                 if((ok = pop3_slowuidl( sock, ctl, countp, newp))!=0)
507                 {
508                     report(stderr, _("protocol error while fetching UIDLs\n"));
509                     return(PS_ERROR);
510                 }
511             }
512             else
513             {
514                 int     num;
515
516                 *newp = 0;
517                 while ((ok = gen_recv(sock, buf, sizeof(buf))) == 0)
518                 {
519                     if (DOTLINE(buf))
520                         break;
521                     else if (sscanf(buf, "%d %s", &num, id) == 2)
522                     {
523                         struct idlist   *new;
524
525                         new = save_str(&ctl->newsaved, id, UID_UNSEEN);
526                         new->val.status.num = num;
527
528                         if (str_in_list(&ctl->oldsaved, id, FALSE)) {
529                             new->val.status.mark = UID_SEEN;
530                             str_set_mark(&ctl->oldsaved, id, UID_SEEN);
531                         }
532                         else
533                             (*newp)++;
534                     }
535                 }
536             }
537         }
538     }
539
540     return(PS_SUCCESS);
541 }
542
543 static int pop3_getsizes(int sock, int count, int *sizes)
544 /* capture the sizes of all messages */
545 {
546     int ok;
547
548     if ((ok = gen_transact(sock, "LIST")) != 0)
549         return(ok);
550     else
551     {
552         char buf [POPBUFSIZE+1];
553
554         while ((ok = gen_recv(sock, buf, sizeof(buf))) == 0)
555         {
556             int num, size;
557
558             if (DOTLINE(buf))
559                 break;
560             else if (sscanf(buf, "%d %d", &num, &size) == 2)
561                 sizes[num - 1] = size;
562         }
563
564         return(ok);
565     }
566 }
567
568 static int pop3_is_old(int sock, struct query *ctl, int num)
569 /* is the given message old? */
570 {
571     if (!ctl->oldsaved)
572         return (num <= last);
573     else
574         return (str_in_list(&ctl->oldsaved,
575                             str_find(&ctl->newsaved, num), FALSE));
576 }
577
578 #ifdef UNUSED
579 /*
580  * We could use this to fetch headers only as we do for IMAP.  The trouble 
581  * is that there's no way to fetch the body only.  So the following RETR 
582  * would have to re-fetch the header.  Enough messages have longer headers
583  * than bodies to make this a net loss.
584  */
585 static int pop_fetch_headers(int sock, struct query *ctl,int number,int *lenp)
586 /* request headers of nth message */
587 {
588     int ok;
589     char buf[POPBUFSIZE+1];
590
591     gen_send(sock, "TOP %d 0", number);
592     if ((ok = pop3_ok(sock, buf)) != 0)
593         return(ok);
594
595     *lenp = -1;         /* we got sizes from the LIST response */
596
597     return(PS_SUCCESS);
598 }
599 #endif /* UNUSED */
600
601 static int pop3_fetch(int sock, struct query *ctl, int number, int *lenp)
602 /* request nth message */
603 {
604     int ok;
605     char buf[POPBUFSIZE+1];
606
607 #ifdef SDPS_ENABLE
608     /*
609      * See http://www.demon.net/services/mail/sdps-tech.html
610      * for a description of what we're parsing here.
611      */
612     if (ctl->server.sdps)
613     {
614         int     linecount = 0;
615
616         sdps_envfrom = (char *)NULL;
617         sdps_envto = (char *)NULL;
618         gen_send(sock, "*ENV %d", number);
619         do {
620             if (gen_recv(sock, buf, sizeof(buf)))
621             {
622                 break;
623             }
624             linecount++;
625             switch (linecount) {
626             case 4:
627                 /* No need to wrap envelope from address */
628                 sdps_envfrom = xmalloc(strlen(buf)+1);
629                 strcpy(sdps_envfrom,buf);
630                 break;
631             case 5:
632                 /* Wrap address with To: <> so nxtaddr() likes it */
633                 sdps_envto = xmalloc(strlen(buf)+7);
634                 sprintf(sdps_envto,"To: <%s>",buf);
635                 break;
636             }
637         } while
638             (!(buf[0] == '.' && (buf[1] == '\r' || buf[1] == '\n' || buf[1] == '\0')));
639     }
640 #endif /* SDPS_ENABLE */
641
642     /*
643      * Though the POP RFCs don't document this fact, on almost every
644      * POP3 server I know of messages are marked "seen" only at the
645      * time the OK response to a RETR is issued.
646      *
647      * This means we can use TOP to fetch the message without setting its
648      * seen flag.  This is good!  It means that if the protocol exchange
649      * craps out during the message, it will still be marked `unseen' on
650      * the server.  (Exception: in early 1999 SpryNet's POP3 servers were
651      * reported to mark messages seen on a TOP fetch.)
652      *
653      * However...*don't* do this if we're using keep to suppress deletion!
654      * In that case, marking the seen flag is the only way to prevent the
655      * message from being re-fetched on subsequent runs.
656      *
657      * Also use RETR if fetchall is on.  This gives us a workaround
658      * for servers like usa.net's that bungle TOP.  It's pretty
659      * harmless because fetchall guarantees that any message dropped
660      * by an interrupted RETR will be picked up on the next poll of the
661      * site.
662      *
663      * We take advantage here of the fact that, according to all the
664      * POP RFCs, "if the number of lines requested by the POP3 client
665      * is greater than than the number of lines in the body, then the
666      * POP3 server sends the entire message.").
667      *
668      * The line count passed (99999999) is the maximum value CompuServe will
669      * accept; it's much lower than the natural value 2147483646 (the maximum
670      * twos-complement signed 32-bit integer minus 1) */
671     if (ctl->keep || ctl->fetchall)
672         gen_send(sock, "RETR %d", number);
673     else
674         gen_send(sock, "TOP %d 99999999", number);
675     if ((ok = pop3_ok(sock, buf)) != 0)
676         return(ok);
677
678     *lenp = -1;         /* we got sizes from the LIST response */
679
680     return(PS_SUCCESS);
681 }
682
683 static int pop3_delete(int sock, struct query *ctl, int number)
684 /* delete a given message */
685 {
686     /* actually, mark for deletion -- doesn't happen until QUIT time */
687     return(gen_transact(sock, "DELE %d", number));
688 }
689
690 static int pop3_logout(int sock, struct query *ctl)
691 /* send logout command */
692 {
693     int ok;
694
695     ok = gen_transact(sock, "QUIT");
696     if (!ok)
697         expunge_uids(ctl);
698
699     if (ctl->lastid)
700     {
701         free(ctl->lastid);
702         ctl->lastid = NULL;
703     }
704
705     return(ok);
706 }
707
708 const static struct method pop3 =
709 {
710     "POP3",             /* Post Office Protocol v3 */
711 #if INET6_ENABLE
712     "pop3",             /* standard POP3 port */
713     "pop3s",            /* ssl POP3 port */
714 #else /* INET6_ENABLE */
715     110,                /* standard POP3 port */
716     995,                /* ssl POP3 port */
717 #endif /* INET6_ENABLE */
718     FALSE,              /* this is not a tagged protocol */
719     TRUE,               /* this uses a message delimiter */
720     pop3_ok,            /* parse command response */
721     NULL,               /* no password canonicalization */
722     pop3_getauth,       /* get authorization */
723     pop3_getrange,      /* query range of messages */
724     pop3_getsizes,      /* we can get a list of sizes */
725     pop3_is_old,        /* how do we tell a message is old? */
726     pop3_fetch,         /* request given message */
727     NULL,               /* no way to fetch body alone */
728     NULL,               /* no message trailer */
729     pop3_delete,        /* how to delete a message */
730     pop3_logout,        /* log out, we're done */
731     FALSE,              /* no, we can't re-poll */
732 };
733
734 int doPOP3 (struct query *ctl)
735 /* retrieve messages using POP3 */
736 {
737 #ifndef MBOX
738     if (ctl->mailboxes->id) {
739         fprintf(stderr,_("Option --remote is not supported with POP3\n"));
740         return(PS_SYNTAX);
741     }
742 #endif /* MBOX */
743     peek_capable = !ctl->fetchall;
744     return(do_protocol(ctl, &pop3));
745 }
746 #endif /* POP3_ENABLE */
747
748 /* pop3.c ends here */