]> Pileus Git - ~andy/fetchmail/blob - pop3.c
7684b1a179ed3d1a3b9efab83f305202597e74d4
[~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 #if OPIE_ENABLE
171         /* see RFC1938: A One-Time Password System */
172         if (challenge = strstr(lastok, "otp-")) {
173           char response[OPIE_RESPONSE_MAX+1];
174           int i;
175
176           i = opiegenerator(challenge, !strcmp(ctl->password, "opie") ? "" : ctl->password, response);
177           if ((i == -2) && !run.poll_interval) {
178             char secret[OPIE_SECRET_MAX+1];
179             fprintf(stderr, _("Secret pass phrase: "));
180             if (opiereadpass(secret, sizeof(secret), 0))
181               i = opiegenerator(challenge,  secret, response);
182             memset(secret, 0, sizeof(secret));
183           };
184
185           if (i) {
186             ok = PS_ERROR;
187             break;
188           };
189
190           ok = gen_transact(sock, "PASS %s", response);
191           break;
192         }
193 #endif /* OPIE_ENABLE */
194
195         /*
196          * CAPA command may return a list of available mechanisms.
197          * if it doesn't, no harm done, we just fall back to a 
198          * plain login.
199          *
200          * APOP was introduced in RFC 1450, and CAPA not until
201          * RFC2449. So the < check is an easy way to prevent CAPA from
202          * being sent to the more primitive POP3 servers dating from
203          * RFC 1081 and RFC 1225, which seem more likely to choke on
204          * it.  This certainly catches IMAP-2000's POP3 gateway.
205          * 
206          * These authentication methods are blessed by RFC1734,
207          * describing the POP3 AUTHentication command. 
208          */
209         if (ctl->server.authenticate == A_ANY 
210             && strchr(greeting, '<') 
211             && gen_transact(sock, "CAPA") == 0)
212         {
213 #if defined(GSSAPI)
214             flag has_gssapi = FALSE;
215 #endif /* defined(GSSAPI) */
216 #if defined(KERBEROS_V4) || defined(KERBEROS_V5)
217             flag has_kerberos = FALSE;
218 #endif /* defined(KERBEROS_V4) || defined(KERBEROS_V5) */
219             flag has_cram = FALSE;
220 #ifdef OPIE_ENABLE
221             flag has_opie = FALSE;
222 #endif /* OPIE_ENABLE */
223             char buffer[64];
224
225             /* determine what authentication methods we have available */
226             while ((ok = gen_recv(sock, buffer, sizeof(buffer))) == 0)
227             {
228                 if (DOTLINE(buffer))
229                     break;
230 #if defined(GSSAPI)
231                 if (strstr(buffer, "GSSAPI"))
232                     has_gssapi = TRUE;
233 #endif /* defined(GSSAPI) */
234 #if defined(KERBEROS_V4) || defined(KERBEROS_V5)
235                 if (strstr(buffer, "KERBEROS_V4"))
236                     has_kerberos = TRUE;
237 #endif /* defined(KERBEROS_V4) || defined(KERBEROS_V5) */
238                 if (strstr(buffer, "CRAM-MD5"))
239                     has_cram = TRUE;
240 #ifdef OPIE_ENABLE
241                 if (strstr(buffer, "X-OTP"))
242                     has_opie = TRUE;
243 #endif /* OPIE_ENABLE */
244             }
245
246 #if defined(GSSAPI)
247             if ((ctl->server.authenticate == A_ANY 
248                  || ctl->server.authenticate==A_GSSAPI)
249                 && has_gssapi)
250                 return(do_gssauth(sock, "AUTH", 
251                                   ctl->server.truename, ctl->remotename));
252 #endif /* defined(GSSAPI) */
253 #if defined(KERBEROS_V4) || defined(KERBEROS_V5)
254             if ((ctl->server.authenticate == A_ANY 
255                  || ctl->server.authenticate==A_KERBEROS_V4
256                  || ctl->server.authenticate==A_KERBEROS_V5)
257                 && has_kerberos)
258                 return(do_rfc1731(sock, "AUTH", ctl->server.truename));
259 #endif /* defined(KERBEROS_V4) || defined(KERBEROS_V5) */
260             if (has_cram)
261                 return(do_cram_md5(sock, "AUTH", ctl));
262 #ifdef OPIE_ENABLE
263             if (has_opie)
264                 do_otp(sock, "AUTH", ctl)
265 #endif /* OPIE_ENABLE */
266        }
267
268         /* ordinary validation, no one-time password or RPA */ 
269         gen_transact(sock, "USER %s", ctl->remotename);
270         ok = gen_transact(sock, "PASS %s", ctl->password);
271         break;
272
273     case P_APOP:
274         /* build MD5 digest from greeting timestamp + password */
275         /* find start of timestamp */
276         for (start = greeting;  *start != 0 && *start != '<';  start++)
277             continue;
278         if (*start == 0) {
279             report(stderr,
280                    _("Required APOP timestamp not found in greeting\n"));
281             return(PS_AUTHFAIL);
282         }
283
284         /* find end of timestamp */
285         for (end = start;  *end != 0  && *end != '>';  end++)
286             continue;
287         if (*end == 0 || end == start + 1) {
288             report(stderr, 
289                    _("Timestamp syntax error in greeting\n"));
290             return(PS_AUTHFAIL);
291         }
292         else
293             *++end = '\0';
294
295         /* copy timestamp and password into digestion buffer */
296         xalloca(msg, char *, (end-start+1) + strlen(ctl->password) + 1);
297         strcpy(msg,start);
298         strcat(msg,ctl->password);
299
300         strcpy(ctl->digest, MD5Digest((unsigned char *)msg));
301
302         ok = gen_transact(sock, "APOP %s %s", ctl->remotename, ctl->digest);
303         break;
304
305     case P_RPOP:
306         if ((ok = gen_transact(sock,"USER %s", ctl->remotename)) == 0)
307             ok = gen_transact(sock, "RPOP %s", ctl->password);
308         break;
309
310     default:
311         report(stderr, _("Undefined protocol request in POP3_auth\n"));
312         ok = PS_ERROR;
313     }
314
315     if (ok != 0)
316     {
317         /* maybe we detected a lock-busy condition? */
318         if (ok == PS_LOCKBUSY)
319             report(stderr, _("lock busy!  Is another session active?\n")); 
320
321         return(ok);
322     }
323
324     /*
325      * Empirical experience shows some server/OS combinations
326      * may need a brief pause even after any lockfiles on the
327      * server are released, to give the server time to finish
328      * copying back very large mailfolders from the temp-file...
329      * this is only ever an issue with extremely large mailboxes.
330      */
331     sleep(3); /* to be _really_ safe, probably need sleep(5)! */
332
333     /* we're peek-capable if use of TOP is enabled */
334     peek_capable = !(ctl->fetchall || ctl->keep);
335
336     /* we're approved */
337     return(PS_SUCCESS);
338 }
339
340 static int
341 pop3_gettopid( int sock, int num , char *id)
342 {
343     int ok;
344     int got_it;
345     char buf [POPBUFSIZE+1];
346     sprintf( buf, "TOP %d 1", num );
347     if ((ok = gen_transact(sock, buf )) != 0)
348        return ok; 
349     got_it = 0;
350     while ((ok = gen_recv(sock, buf, sizeof(buf))) == 0) 
351     {
352         if (DOTLINE(buf))
353             break;
354         if ( ! got_it && ! strncasecmp("Message-Id:", buf, 11 )) {
355             got_it = 1;
356             /* prevent stack overflows */
357             buf[IDLEN+12] = 0;
358             sscanf( buf+12, "%s", id);
359         }
360     }
361     return 0;
362 }
363
364 static int
365 pop3_slowuidl( int sock,  struct query *ctl, int *countp, int *newp)
366 {
367     /* This approach tries to get the message headers from the
368      * remote hosts and compares the message-id to the already known
369      * ones:
370      *  + if the first message containes a new id, all messages on
371      *    the server will be new
372      *  + if the first is known, try to estimate the last known message
373      *    on the server and check. If this works you know the total number
374      *    of messages to get.
375      *  + Otherwise run a binary search to determine the last known message
376      */
377     int ok, nolinear = 0;
378     int first_nr, list_len, try_id, try_nr, add_id;
379     int num;
380     char id [IDLEN+1];
381     
382     if( (ok = pop3_gettopid( sock, 1, id )) != 0 )
383         return ok;
384     
385     if( ( first_nr = str_nr_in_list(&ctl->oldsaved, id) ) == -1 ) {
386         /* the first message is unknown -> all messages are new */
387         *newp = *countp;        
388         return 0;
389     }
390
391     /* check where we expect the latest known message */
392     list_len = count_list( &ctl->oldsaved );
393     try_id = list_len  - first_nr; /* -1 + 1 */
394     if( try_id > 1 ) {
395         if( try_id <= *countp ) {
396             if( (ok = pop3_gettopid( sock, try_id, id )) != 0 )
397                 return ok;
398     
399             try_nr = str_nr_last_in_list(&ctl->oldsaved, id);
400         } else {
401             try_id = *countp+1;
402             try_nr = -1;
403         }
404         if( try_nr != list_len -1 ) {
405             /* some messages inbetween have been deleted... */
406             if( try_nr == -1 ) {
407                 nolinear = 1;
408
409                 for( add_id = 1<<30; add_id > try_id-1; add_id >>= 1 )
410                     ;
411                 for( ; add_id; add_id >>= 1 ) {
412                     if( try_nr == -1 ) {
413                         if( try_id - add_id <= 1 ) {
414                             continue;
415                         }
416                         try_id -= add_id;
417                     } else 
418                         try_id += add_id;
419                     
420                     if( (ok = pop3_gettopid( sock, try_id, id )) != 0 )
421                         return ok;
422                     try_nr = str_nr_in_list(&ctl->oldsaved, id);
423                 }
424                 if( try_nr == -1 ) {
425                     try_id--;
426                 }
427             } else {
428                 report(stderr, 
429                        _("Messages inserted into list on server. Cannot handle this.\n"));
430                 return -1;
431             }
432         } 
433     }
434     /* the first try_id messages are known -> copy them to the newsaved list */
435     for( num = first_nr; num < list_len; num++ )
436     {
437         struct idlist   *new = save_str(&ctl->newsaved, 
438                                 str_from_nr_list(&ctl->oldsaved, num),
439                                 UID_UNSEEN);
440         new->val.status.num = num - first_nr + 1;
441     }
442
443     if( nolinear ) {
444         free_str_list(&ctl->oldsaved);
445         ctl->oldsaved = 0;
446         last = try_id;
447     }
448
449     *newp = *countp - try_id;
450     return 0;
451 }
452
453 static int pop3_getrange(int sock, 
454                          struct query *ctl,
455                          const char *folder,
456                          int *countp, int *newp, int *bytes)
457 /* get range of messages to be fetched */
458 {
459     int ok;
460     char buf [POPBUFSIZE+1];
461
462     /* Ensure that the new list is properly empty */
463     ctl->newsaved = (struct idlist *)NULL;
464
465 #ifdef MBOX
466     /* Alain Knaff suggests this, but it's not RFC standard */
467     if (folder)
468         if ((ok = gen_transact(sock, "MBOX %s", folder)))
469             return ok;
470 #endif /* MBOX */
471
472     /* get the total message count */
473     gen_send(sock, "STAT");
474     ok = pop3_ok(sock, buf);
475     if (ok == 0)
476         sscanf(buf,"%d %d", countp, bytes);
477     else
478         return(ok);
479
480     /*
481      * Newer, RFC-1725-conformant POP servers may not have the LAST command.
482      * We work as hard as possible to hide this ugliness, but it makes 
483      * counting new messages intrinsically quadratic in the worst case.
484      */
485     last = 0;
486     *newp = -1;
487     if (*countp > 0 && !ctl->fetchall)
488     {
489         char id [IDLEN+1];
490
491         if (!ctl->server.uidl) {
492             gen_send(sock, "LAST");
493             ok = pop3_ok(sock, buf);
494         } else
495             ok = 1;
496         if (ok == 0)
497         {
498             if (sscanf(buf, "%d", &last) == 0)
499             {
500                 report(stderr, _("protocol error\n"));
501                 return(PS_ERROR);
502             }
503             *newp = (*countp - last);
504         }
505         else
506         {
507             /* grab the mailbox's UID list */
508             if ((ok = gen_transact(sock, "UIDL")) != 0)
509             {
510                 /* don't worry, yet! do it the slow way */
511                 if((ok = pop3_slowuidl( sock, ctl, countp, newp))!=0)
512                 {
513                     report(stderr, _("protocol error while fetching UIDLs\n"));
514                     return(PS_ERROR);
515                 }
516             }
517             else
518             {
519                 int     num;
520
521                 *newp = 0;
522                 while ((ok = gen_recv(sock, buf, sizeof(buf))) == 0)
523                 {
524                     if (DOTLINE(buf))
525                         break;
526                     else if (sscanf(buf, "%d %s", &num, id) == 2)
527                     {
528                         struct idlist   *new;
529
530                         new = save_str(&ctl->newsaved, id, UID_UNSEEN);
531                         new->val.status.num = num;
532
533                         if (str_in_list(&ctl->oldsaved, id, FALSE)) {
534                             new->val.status.mark = UID_SEEN;
535                             str_set_mark(&ctl->oldsaved, id, UID_SEEN);
536                         }
537                         else
538                             (*newp)++;
539                     }
540                 }
541             }
542         }
543     }
544
545     return(PS_SUCCESS);
546 }
547
548 static int pop3_getsizes(int sock, int count, int *sizes)
549 /* capture the sizes of all messages */
550 {
551     int ok;
552
553     if ((ok = gen_transact(sock, "LIST")) != 0)
554         return(ok);
555     else
556     {
557         char buf [POPBUFSIZE+1];
558
559         while ((ok = gen_recv(sock, buf, sizeof(buf))) == 0)
560         {
561             int num, size;
562
563             if (DOTLINE(buf))
564                 break;
565             else if (sscanf(buf, "%d %d", &num, &size) == 2)
566                 sizes[num - 1] = size;
567         }
568
569         return(ok);
570     }
571 }
572
573 static int pop3_is_old(int sock, struct query *ctl, int num)
574 /* is the given message old? */
575 {
576     if (!ctl->oldsaved)
577         return (num <= last);
578     else
579         return (str_in_list(&ctl->oldsaved,
580                             str_find(&ctl->newsaved, num), FALSE));
581 }
582
583 #ifdef UNUSED
584 /*
585  * We could use this to fetch headers only as we do for IMAP.  The trouble 
586  * is that there's no way to fetch the body only.  So the following RETR 
587  * would have to re-fetch the header.  Enough messages have longer headers
588  * than bodies to make this a net loss.
589  */
590 static int pop_fetch_headers(int sock, struct query *ctl,int number,int *lenp)
591 /* request headers of nth message */
592 {
593     int ok;
594     char buf[POPBUFSIZE+1];
595
596     gen_send(sock, "TOP %d 0", number);
597     if ((ok = pop3_ok(sock, buf)) != 0)
598         return(ok);
599
600     *lenp = -1;         /* we got sizes from the LIST response */
601
602     return(PS_SUCCESS);
603 }
604 #endif /* UNUSED */
605
606 static int pop3_fetch(int sock, struct query *ctl, int number, int *lenp)
607 /* request nth message */
608 {
609     int ok;
610     char buf[POPBUFSIZE+1];
611
612 #ifdef SDPS_ENABLE
613     /*
614      * See http://www.demon.net/services/mail/sdps-tech.html
615      * for a description of what we're parsing here.
616      */
617     if (ctl->server.sdps)
618     {
619         int     linecount = 0;
620
621         sdps_envfrom = (char *)NULL;
622         sdps_envto = (char *)NULL;
623         gen_send(sock, "*ENV %d", number);
624         do {
625             if (gen_recv(sock, buf, sizeof(buf)))
626             {
627                 break;
628             }
629             linecount++;
630             switch (linecount) {
631             case 4:
632                 /* No need to wrap envelope from address */
633                 sdps_envfrom = xmalloc(strlen(buf)+1);
634                 strcpy(sdps_envfrom,buf);
635                 break;
636             case 5:
637                 /* Wrap address with To: <> so nxtaddr() likes it */
638                 sdps_envto = xmalloc(strlen(buf)+7);
639                 sprintf(sdps_envto,"To: <%s>",buf);
640                 break;
641             }
642         } while
643             (!(buf[0] == '.' && (buf[1] == '\r' || buf[1] == '\n' || buf[1] == '\0')));
644     }
645 #endif /* SDPS_ENABLE */
646
647     /*
648      * Though the POP RFCs don't document this fact, on almost every
649      * POP3 server I know of messages are marked "seen" only at the
650      * time the OK response to a RETR is issued.
651      *
652      * This means we can use TOP to fetch the message without setting its
653      * seen flag.  This is good!  It means that if the protocol exchange
654      * craps out during the message, it will still be marked `unseen' on
655      * the server.  (Exception: in early 1999 SpryNet's POP3 servers were
656      * reported to mark messages seen on a TOP fetch.)
657      *
658      * However...*don't* do this if we're using keep to suppress deletion!
659      * In that case, marking the seen flag is the only way to prevent the
660      * message from being re-fetched on subsequent runs.
661      *
662      * Also use RETR if fetchall is on.  This gives us a workaround
663      * for servers like usa.net's that bungle TOP.  It's pretty
664      * harmless because fetchall guarantees that any message dropped
665      * by an interrupted RETR will be picked up on the next poll of the
666      * site.
667      *
668      * We take advantage here of the fact that, according to all the
669      * POP RFCs, "if the number of lines requested by the POP3 client
670      * is greater than than the number of lines in the body, then the
671      * POP3 server sends the entire message.").
672      *
673      * The line count passed (99999999) is the maximum value CompuServe will
674      * accept; it's much lower than the natural value 2147483646 (the maximum
675      * twos-complement signed 32-bit integer minus 1) */
676     if (ctl->keep || ctl->fetchall)
677         gen_send(sock, "RETR %d", number);
678     else
679         gen_send(sock, "TOP %d 99999999", number);
680     if ((ok = pop3_ok(sock, buf)) != 0)
681         return(ok);
682
683     *lenp = -1;         /* we got sizes from the LIST response */
684
685     return(PS_SUCCESS);
686 }
687
688 static int pop3_delete(int sock, struct query *ctl, int number)
689 /* delete a given message */
690 {
691     /* actually, mark for deletion -- doesn't happen until QUIT time */
692     return(gen_transact(sock, "DELE %d", number));
693 }
694
695 static int pop3_logout(int sock, struct query *ctl)
696 /* send logout command */
697 {
698     int ok;
699
700     ok = gen_transact(sock, "QUIT");
701     if (!ok)
702         expunge_uids(ctl);
703
704     if (ctl->lastid)
705     {
706         free(ctl->lastid);
707         ctl->lastid = NULL;
708     }
709
710     return(ok);
711 }
712
713 const static struct method pop3 =
714 {
715     "POP3",             /* Post Office Protocol v3 */
716 #if INET6_ENABLE
717     "pop3",             /* standard POP3 port */
718     "pop3s",            /* ssl POP3 port */
719 #else /* INET6_ENABLE */
720     110,                /* standard POP3 port */
721     995,                /* ssl POP3 port */
722 #endif /* INET6_ENABLE */
723     FALSE,              /* this is not a tagged protocol */
724     TRUE,               /* this uses a message delimiter */
725     pop3_ok,            /* parse command response */
726     NULL,               /* no password canonicalization */
727     pop3_getauth,       /* get authorization */
728     pop3_getrange,      /* query range of messages */
729     pop3_getsizes,      /* we can get a list of sizes */
730     pop3_is_old,        /* how do we tell a message is old? */
731     pop3_fetch,         /* request given message */
732     NULL,               /* no way to fetch body alone */
733     NULL,               /* no message trailer */
734     pop3_delete,        /* how to delete a message */
735     pop3_logout,        /* log out, we're done */
736     FALSE,              /* no, we can't re-poll */
737 };
738
739 int doPOP3 (struct query *ctl)
740 /* retrieve messages using POP3 */
741 {
742 #ifndef MBOX
743     if (ctl->mailboxes->id) {
744         fprintf(stderr,_("Option --remote is not supported with POP3\n"));
745         return(PS_SYNTAX);
746     }
747 #endif /* MBOX */
748     peek_capable = !ctl->fetchall;
749     return(do_protocol(ctl, &pop3));
750 }
751 #endif /* POP3_ENABLE */
752
753 /* pop3.c ends here */