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