2 * imap.c -- IMAP2bis/IMAP4 protocol methods
4 * Copyright 1997 by Eric S. Raymond
5 * For license terms, see the file COPYING in this directory.
12 #if defined(STDC_HEADERS)
16 #include "fetchmail.h"
22 #endif /* OPIE_ENABLE */
24 #ifndef strstr /* glibc-2.1 declares this as a macro */
25 extern char *strstr(); /* needed on sysV68 R3V7.1. */
28 /* imap_version values */
29 #define IMAP2 -1 /* IMAP2 or IMAP2BIS, RFC1176 */
30 #define IMAP4 0 /* IMAP4 rev 0, RFC1730 */
31 #define IMAP4rev1 1 /* IMAP4 rev 1, RFC2060 */
33 static int count = 0, recentcount = 0, unseen = 0, deletions = 0;
34 static int expunged, expunge_period, saved_timeout = 0;
35 static int imap_version, preauth;
37 static char capabilities[MSGBUFSIZE+1];
38 static unsigned int *unseen_messages;
40 static int imap_ok(int sock, char *argbuf)
41 /* parse command response */
43 char buf[MSGBUFSIZE+1];
49 if ((ok = gen_recv(sock, buf, sizeof(buf))))
52 /* all tokens in responses are caseblind */
53 for (cp = buf; *cp; cp++)
57 /* interpret untagged status responses */
58 if (strstr(buf, "* CAPABILITY"))
59 strncpy(capabilities, buf + 12, sizeof(capabilities));
60 else if (strstr(buf, "EXISTS"))
64 * Don't trust the message count passed by the server.
65 * Without this check, it might be possible to do a
66 * DNS-spoofing attack that would pass back a ridiculous
67 * count, and allocate a malloc area that would overlap
68 * a portion of the stack.
70 if (count > INT_MAX/sizeof(int))
72 report(stderr, "bogus message count!");
77 * Nasty kluge to handle RFC2177 IDLE. If we know we're idling
78 * we can't wait for the tag matching the IDLE; we have to tell the
79 * server the IDLE is finished by shipping back a DONE when we
80 * see an EXISTS. Only after that will a tagged response be
81 * shipped. The idling flag also gets cleared on a timeout.
83 if (stage == STAGE_IDLE)
85 /* we do our own write and report here to disable tagging */
86 SockWrite(sock, "DONE\r\n", 6);
87 if (outlevel >= O_MONITOR)
88 report(stdout, "IMAP> DONE\n");
90 mytimeout = saved_timeout;
94 else if (strstr(buf, "RECENT"))
96 recentcount = atoi(buf+2);
98 else if (strstr(buf, "PREAUTH"))
101 * The server may decide to make the mailbox read-only,
102 * which causes fetchmail to go into a endless loop
103 * fetching the same message over and over again.
105 * However, for check_only, we use EXAMINE which will
106 * mark the mailbox read-only as per the RFC.
108 * This checks for the condition and aborts if
109 * the mailbox is read-only.
111 * See RFC 2060 section 6.3.1 (SELECT).
112 * See RFC 2060 section 6.3.2 (EXAMINE).
114 else if (!check_only && strstr(buf, "[READ-ONLY]"))
117 (tag[0] != '\0' && strncmp(buf, tag, strlen(tag)));
130 for (cp = buf; !isspace(*cp); cp++)
135 if (strncmp(cp, "OK", 2) == 0)
141 else if (strncmp(cp, "BAD", 3) == 0)
143 else if (strncmp(cp, "NO", 2) == 0)
145 if (stage == STAGE_GETAUTH)
146 return(PS_AUTHFAIL); /* RFC2060, 6.2.2 */
158 static tSmbNtlmAuthRequest request;
159 static tSmbNtlmAuthChallenge challenge;
160 static tSmbNtlmAuthResponse response;
163 * NTLM support by Grant Edwards.
165 * Handle MS-Exchange NTLM authentication method. This is the same
166 * as the NTLM auth used by Samba for SMB related services. We just
167 * encode the packets in base64 instead of sending them out via a
170 * Much source (ntlm.h, smb*.c smb*.h) was borrowed from Samba.
173 static int do_imap_ntlm(int sock, struct query *ctl)
178 gen_send(sock, "AUTHENTICATE NTLM");
180 if ((result = gen_recv(sock, msgbuf, sizeof msgbuf)))
183 if (msgbuf[0] != '+')
186 buildSmbNtlmAuthRequest(&request,ctl->remotename,NULL);
188 if (outlevel >= O_DEBUG)
189 dumpSmbNtlmAuthRequest(stdout, &request);
191 memset(msgbuf,0,sizeof msgbuf);
192 to64frombits (msgbuf, (unsigned char*)&request, SmbLength(&request));
194 if (outlevel >= O_MONITOR)
195 report(stdout, "IMAP> %s\n", msgbuf);
197 strcat(msgbuf,"\r\n");
198 SockWrite (sock, msgbuf, strlen (msgbuf));
200 if ((gen_recv(sock, msgbuf, sizeof msgbuf)))
203 len = from64tobits ((char*)&challenge, msgbuf, sizeof(challenge));
205 if (outlevel >= O_DEBUG)
206 dumpSmbNtlmAuthChallenge(stdout, &challenge);
208 buildSmbNtlmAuthResponse(&challenge, &response,ctl->remotename,ctl->password);
210 if (outlevel >= O_DEBUG)
211 dumpSmbNtlmAuthResponse(stdout, &response);
213 memset(msgbuf,0,sizeof msgbuf);
214 to64frombits (msgbuf, (unsigned char*)&response, SmbLength(&response));
216 if (outlevel >= O_MONITOR)
217 report(stdout, "IMAP> %s\n", msgbuf);
219 strcat(msgbuf,"\r\n");
220 SockWrite (sock, msgbuf, strlen (msgbuf));
222 if ((result = gen_recv (sock, msgbuf, sizeof msgbuf)))
225 if (strstr (msgbuf, "OK"))
232 static int imap_canonicalize(char *result, char *raw, int maxlen)
233 /* encode an IMAP password as per RFC1730's quoting conventions */
238 for (i = 0; i < strlen(raw) && i < maxlen; i++)
240 if ((raw[i] == '\\') || (raw[i] == '"'))
242 result[j++] = raw[i];
249 static int imap_getauth(int sock, struct query *ctl, char *greeting)
250 /* apply for connection authorization */
254 /* probe to see if we're running IMAP4 and can use RFC822.PEEK */
255 capabilities[0] = '\0';
256 if ((ok = gen_transact(sock, "CAPABILITY")) == PS_SUCCESS)
260 /* capability checks are supposed to be caseblind */
261 for (cp = capabilities; *cp; cp++)
264 /* UW-IMAP server 10.173 notifies in all caps, but RFC2060 says we
265 should expect a response in mixed-case */
266 if (strstr(capabilities, "IMAP4REV1"))
268 imap_version = IMAP4rev1;
269 if (outlevel >= O_DEBUG)
270 report(stdout, GT_("Protocol identified as IMAP4 rev 1\n"));
274 imap_version = IMAP4;
275 if (outlevel >= O_DEBUG)
276 report(stdout, GT_("Protocol identified as IMAP4 rev 0\n"));
279 else if (ok == PS_ERROR)
281 imap_version = IMAP2;
282 if (outlevel >= O_DEBUG)
283 report(stdout, GT_("Protocol identified as IMAP2 or IMAP2BIS\n"));
288 peek_capable = (imap_version >= IMAP4);
291 * Assumption: expunges are cheap, so we want to do them
292 * after every message unless user said otherwise.
294 if (NUM_SPECIFIED(ctl->expunge))
295 expunge_period = NUM_VALUE_OUT(ctl->expunge);
300 * Handle idling. We depend on coming through here on startup
301 * and after each timeout (including timeouts during idles).
303 if (strstr(capabilities, "IDLE") && ctl->idle)
306 if (outlevel >= O_VERBOSE)
307 report(stdout, GT_("will idle after poll\n"));
311 * If either (a) we saw a PREAUTH token in the greeting, or
312 * (b) the user specified ssh preauthentication, then we're done.
314 if (preauth || ctl->server.authenticate == A_SSH)
316 preauth = FALSE; /* reset for the next session */
321 * Time to authenticate the user.
322 * Try the protocol variants that don't require passwords first.
327 if ((ctl->server.authenticate == A_ANY
328 || ctl->server.authenticate == A_GSSAPI)
329 && strstr(capabilities, "AUTH=GSSAPI"))
330 if(ok = do_gssauth(sock, "AUTHENTICATE", ctl->server.truename, ctl->remotename))
332 /* SASL cancellation of authentication */
334 if(ctl->server.authenticate != A_ANY)
342 if ((ctl->server.authenticate == A_ANY
343 || ctl->server.authenticate == A_KERBEROS_V4
344 || ctl->server.authenticate == A_KERBEROS_V5)
345 && strstr(capabilities, "AUTH=KERBEROS_V4"))
347 if ((ok = do_rfc1731(sock, "AUTHENTICATE", ctl->server.truename)))
349 /* SASL cancellation of authentication */
351 if(ctl->server.authenticate != A_ANY)
357 #endif /* KERBEROS_V4 */
360 * No such luck. OK, now try the variants that mask your password
361 * in a challenge-response.
364 if ((ctl->server.authenticate == A_ANY
365 || ctl->server.authenticate == A_CRAM_MD5)
366 && strstr(capabilities, "AUTH=CRAM-MD5"))
368 if ((ok = do_cram_md5 (sock, "AUTHENTICATE", ctl, NULL)))
370 /* SASL cancellation of authentication */
372 if(ctl->server.authenticate != A_ANY)
380 if ((ctl->server.authenticate == A_ANY
381 || ctl->server.authenticate == A_OTP)
382 && strstr(capabilities, "AUTH=X-OTP"))
383 if ((ok = do_otp(sock, "AUTHENTICATE", ctl)))
385 /* SASL cancellation of authentication */
387 if(ctl->server.authenticate != A_ANY)
393 if (ctl->server.authenticate == A_OTP)
396 GT_("Required OTP capability not compiled into fetchmail\n"));
398 #endif /* OPIE_ENABLE */
401 if ((ctl->server.authenticate == A_ANY
402 || ctl->server.authenticate == A_NTLM)
403 && strstr (capabilities, "AUTH=NTLM")) {
404 if ((ok = do_imap_ntlm(sock, ctl)))
406 /* SASL cancellation of authentication */
408 if(ctl->server.authenticate != A_ANY)
415 if (ctl->server.authenticate == A_NTLM)
418 GT_("Required NTLM capability not compiled into fetchmail\n"));
420 #endif /* NTLM_ENABLE */
422 #ifdef __UNUSED__ /* The Cyrus IMAP4rev1 server chokes on this */
423 /* this handles either AUTH=LOGIN or AUTH-LOGIN */
424 if ((imap_version >= IMAP4rev1) && (!strstr(capabilities, "LOGIN")))
427 GT_("Required LOGIN capability not supported by server\n"));
429 #endif /* __UNUSED__ */
431 /* we're stuck with sending the password en clair */
432 if ((ctl->server.authenticate == A_ANY
433 || ctl->server.authenticate == A_PASSWORD)
434 && !strstr (capabilities, "LOGINDISABLED"))
436 /* these sizes guarantee no buffer overflow */
437 char remotename[NAMELEN*2+1], password[PASSWORDLEN*2+1];
439 imap_canonicalize(remotename, ctl->remotename, NAMELEN);
440 imap_canonicalize(password, ctl->password, PASSWORDLEN);
442 strcpy(shroud, password);
443 ok = gen_transact(sock, "LOGIN \"%s\" \"%s\"", remotename, password);
447 /* SASL cancellation of authentication */
449 if(ctl->server.authenticate != A_ANY)
459 static int internal_expunge(int sock)
460 /* ship an expunge, resetting associated counters */
464 if ((ok = gen_transact(sock, "EXPUNGE")))
467 expunged += deletions;
470 #ifdef IMAP_UID /* not used */
472 #endif /* IMAP_UID */
477 static int imap_idle(int sock)
478 /* start an RFC2177 IDLE */
481 saved_timeout = mytimeout;
484 return (gen_transact(sock, "IDLE"));
487 static int imap_getrange(int sock,
490 int *countp, int *newp, int *bytes)
491 /* get range of messages to be fetched */
494 char buf[MSGBUFSIZE+1], *cp;
496 /* find out how many messages are waiting */
502 * We have to have an expunge here, otherwise the re-poll will
503 * infinite-loop picking up un-expunged messages -- unless the
504 * expunge period is one and we've been nuking each message
505 * just after deletion.
509 ok = internal_expunge(sock);
512 report(stderr, GT_("expunge failed\n"));
518 * recentcount is already set here by the last imap command which
519 * returned RECENT on detecting new mail. if recentcount is 0, wait
523 /* this is a while loop because imap_idle() might return on other
524 * mailbox changes also */
525 while (recentcount == 0 && do_idle) {
527 ok = imap_idle(sock);
530 report(stderr, GT_("re-poll failed\n"));
534 /* if recentcount is 0, return no mail */
535 if (recentcount == 0)
537 if (outlevel >= O_DEBUG)
538 report(stdout, GT_("%d messages waiting after re-poll\n"), count);
543 ok = gen_transact(sock,
544 check_only ? "EXAMINE \"%s\"" : "SELECT \"%s\"",
545 folder ? folder : "INBOX");
548 report(stderr, GT_("mailbox selection failed\n"));
551 else if (outlevel >= O_DEBUG)
552 report(stdout, GT_("%d messages waiting after first poll\n"), count);
554 /* no messages? then we may need to idle until we get some */
555 while (count == 0 && do_idle) {
556 ok = imap_idle(sock);
559 report(stderr, GT_("re-poll failed\n"));
565 * We should have an expunge here to
566 * a) avoid fetching deleted mails during 'fetchall'
567 * b) getting a wrong count of mails during 'no fetchall'
569 if (!check_only && !ctl->keep && count > 0)
571 ok = internal_expunge(sock);
574 report(stderr, GT_("expunge failed\n"));
577 if (outlevel >= O_DEBUG)
578 report(stdout, GT_("%d messages waiting after expunge\n"), count);
585 /* OK, now get a count of unseen messages and their indices */
586 if (!ctl->fetchall && count > 0)
589 free(unseen_messages);
590 unseen_messages = xmalloc(count * sizeof(unsigned int));
591 memset(unseen_messages, 0, count * sizeof(unsigned int));
594 gen_send(sock, "SEARCH UNSEEN");
596 ok = gen_recv(sock, buf, sizeof(buf));
599 report(stderr, GT_("search for unseen messages failed\n"));
602 else if ((cp = strstr(buf, "* SEARCH")))
606 cp += 8; /* skip "* SEARCH" */
608 while (*cp && unseen < count)
610 /* skip whitespace */
611 while (*cp && isspace(*cp))
616 * Message numbers are between 1 and 2^32 inclusive,
617 * so unsigned int is large enough.
619 unseen_messages[unseen]=(unsigned int)strtol(cp,&ep,10);
621 if (outlevel >= O_DEBUG)
623 GT_("%u is unseen\n"),
624 unseen_messages[unseen]);
632 (tag[0] != '\0' && strncmp(buf, tag, strlen(tag)));
644 static int imap_getsizes(int sock, int count, int *sizes)
645 /* capture the sizes of all messages */
647 char buf [MSGBUFSIZE+1];
650 * Some servers (as in, PMDF5.1-9.1 under OpenVMS 6.1)
651 * won't accept 1:1 as valid set syntax. Some implementors
652 * should be taken out and shot for excessive anality.
654 * Microsoft Exchange (brain-dead piece of crap that it is)
655 * sometimes gets its knickers in a knot about bodiless messages.
656 * You may see responses like this:
658 * fetchmail: IMAP> A0004 FETCH 1:9 RFC822.SIZE
659 * fetchmail: IMAP< * 2 FETCH (RFC822.SIZE 1187)
660 * fetchmail: IMAP< * 3 FETCH (RFC822.SIZE 3954)
661 * fetchmail: IMAP< * 4 FETCH (RFC822.SIZE 1944)
662 * fetchmail: IMAP< * 5 FETCH (RFC822.SIZE 2933)
663 * fetchmail: IMAP< * 6 FETCH (RFC822.SIZE 1854)
664 * fetchmail: IMAP< * 7 FETCH (RFC822.SIZE 34054)
665 * fetchmail: IMAP< * 8 FETCH (RFC822.SIZE 5561)
666 * fetchmail: IMAP< * 9 FETCH (RFC822.SIZE 1101)
667 * fetchmail: IMAP< A0004 NO The requested item could not be found.
669 * This means message 1 has only headers. For kicks and grins
670 * you can telnet in and look:
672 * A003 NO The requested item could not be found.
673 * A004 fetch 1 rfc822.header
674 * A004 NO The requested item could not be found.
676 * * 1 FETCH (BODY ("TEXT" "PLAIN" ("CHARSET" "US-ASCII") NIL NIL "7BIT" 35 3))
677 * A006 OK FETCH completed.
679 * To get around this, we terminate the read loop on a NO and count
680 * on the fact that the sizes array has been preinitialized with a
681 * known-bad size value.
684 gen_send(sock, "FETCH 1 RFC822.SIZE");
686 gen_send(sock, "FETCH 1:%d RFC822.SIZE", count);
689 unsigned int num, size;
692 if ((ok = gen_recv(sock, buf, sizeof(buf))))
694 else if (strstr(buf, "OK") || strstr(buf, "NO"))
696 else if (sscanf(buf, "* %u FETCH (RFC822.SIZE %u)", &num, &size) == 2) {
697 if (num > 0 && num <= count)
698 sizes[num - 1] = size;
700 report(stderr, "Warning: ignoring bogus data for message sizes returned by the server.\n");
707 static int imap_is_old(int sock, struct query *ctl, int number)
708 /* is the given message old? */
714 * Expunges change the fetch numbers, but unseen_messages contains
715 * indices from before any expungees were done. So neither the
716 * argument nor the values in message_sequence need to be decremented.
720 for (i = 0; i < unseen; i++)
721 if (unseen_messages[i] == number)
730 static char *skip_token(char *ptr)
732 while(isspace(*ptr)) ptr++;
733 while(!isspace(*ptr) && !iscntrl(*ptr)) ptr++;
734 while(isspace(*ptr)) ptr++;
738 static int imap_fetch_headers(int sock, struct query *ctl,int number,int *lenp)
739 /* request headers of nth message */
741 char buf [MSGBUFSIZE+1];
744 /* expunges change the fetch numbers */
748 * This is blessed by RFC1176, RFC1730, RFC2060.
749 * According to the RFCs, it should *not* set the \Seen flag.
751 gen_send(sock, "FETCH %d RFC822.HEADER", number);
753 /* looking for FETCH response */
759 if ((ok = gen_recv(sock, buf, sizeof(buf))))
761 ptr = skip_token(buf); /* either "* " or "AXXXX " */
762 if (sscanf(ptr, "%d FETCH (%*s {%d}", &num, lenp) == 2)
764 /* try to recover from chronically fucked-up M$ Exchange servers */
765 else if (!strncmp(ptr, "NO", 2))
766 return(PS_TRANSIENT);
767 else if (!strncmp(ptr, "BAD", 3))
768 return(PS_TRANSIENT);
777 static int imap_fetch_body(int sock, struct query *ctl, int number, int *lenp)
778 /* request body of nth message */
780 char buf [MSGBUFSIZE+1], *cp;
783 /* expunges change the fetch numbers */
787 * If we're using IMAP4, we can fetch the message without setting its
788 * seen flag. This is good! It means that if the protocol exchange
789 * craps out during the message, it will still be marked `unseen' on
792 * However...*don't* do this if we're using keep to suppress deletion!
793 * In that case, marking the seen flag is the only way to prevent the
794 * message from being re-fetched on subsequent runs (and according
795 * to RFC2060 p.43 this fetch should set Seen as a side effect).
797 * According to RFC2060, and Mark Crispin the IMAP maintainer,
798 * FETCH %d BODY[TEXT] and RFC822.TEXT are "functionally
799 * equivalent". However, we know of at least one server that
800 * treats them differently in the presence of MIME attachments;
801 * the latter form downloads the attachment, the former does not.
802 * The server is InterChange, and the fool who implemented this
803 * misfeature ought to be strung up by his thumbs.
805 * When I tried working around this by disabling use of the 4rev1 form,
806 * I found that doing this breaks operation with M$ Exchange.
807 * Annoyingly enough, Exchange's refusal to cope is technically legal
808 * under RFC2062. Trust Microsoft, the Great Enemy of interoperability
809 * standards, to find a way to make standards compliance irritating....
811 switch (imap_version)
813 case IMAP4rev1: /* RFC 2060 */
815 gen_send(sock, "FETCH %d BODY.PEEK[TEXT]", number);
817 gen_send(sock, "FETCH %d BODY[TEXT]", number);
820 case IMAP4: /* RFC 1730 */
822 gen_send(sock, "FETCH %d RFC822.TEXT.PEEK", number);
824 gen_send(sock, "FETCH %d RFC822.TEXT", number);
827 default: /* RFC 1176 */
828 gen_send(sock, "FETCH %d RFC822.TEXT", number);
832 /* looking for FETCH response */
836 if ((ok = gen_recv(sock, buf, sizeof(buf))))
839 (!strstr(buf+4, "FETCH") || sscanf(buf+2, "%d", &num) != 1);
845 * Try to extract a length from the FETCH response. RFC2060 requires
846 * it to be present, but at least one IMAP server (Novell GroupWise)
849 if ((cp = strchr(buf, '{')))
850 *lenp = atoi(cp + 1);
852 *lenp = -1; /* missing length part in FETCH reponse */
857 static int imap_trail(int sock, struct query *ctl, int number)
858 /* discard tail of FETCH response after reading message text */
860 /* expunges change the fetch numbers */
861 /* number -= expunged; */
865 char buf[MSGBUFSIZE+1];
868 if ((ok = gen_recv(sock, buf, sizeof(buf))))
871 /* UW IMAP returns "OK FETCH", Cyrus returns "OK Completed" */
872 if (strstr(buf, "OK"))
877 * Any IMAP server that fails to set Seen on a BODY[TEXT]
878 * fetch violates RFC2060 p.43 (top). This becomes an issue
879 * when keep is on, because seen messages aren't deleted and
880 * get refetched on each poll. As a workaround, if keep is on
881 * we can set the Seen flag explicitly.
883 * This code isn't used yet because we don't know of any IMAP
884 * servers broken in this way.
887 if ((ok = gen_transact(sock,
888 imap_version == IMAP4
889 ? "STORE %d +FLAGS.SILENT (\\Seen)"
890 : "STORE %d +FLAGS (\\Seen)",
893 #endif /* __UNUSED__ */
899 static int imap_delete(int sock, struct query *ctl, int number)
900 /* set delete flag for given message */
904 /* expunges change the fetch numbers */
908 * Use SILENT if possible as a minor throughput optimization.
909 * Note: this has been dropped from IMAP4rev1.
911 * We set Seen because there are some IMAP servers (notably HP
912 * OpenMail) that do message-receipt DSNs, but only when the seen
913 * bit is set. This is the appropriate time -- we get here right
914 * after the local SMTP response that says delivery was
917 if ((ok = gen_transact(sock,
918 imap_version == IMAP4
919 ? "STORE %d +FLAGS.SILENT (\\Seen \\Deleted)"
920 : "STORE %d +FLAGS (\\Seen \\Deleted)",
927 * We do an expunge after expunge_period messages, rather than
928 * just before quit, so that a line hit during a long session
929 * won't result in lots of messages being fetched again during
932 if (NUM_NONZERO(expunge_period) && (deletions % expunge_period) == 0)
933 internal_expunge(sock);
938 static int imap_logout(int sock, struct query *ctl)
939 /* send logout command */
941 /* if any un-expunged deletions remain, ship an expunge now */
943 internal_expunge(sock);
946 /* Memory clean-up */
948 free(unseen_messages);
949 #endif /* USE_SEARCH */
951 return(gen_transact(sock, "LOGOUT"));
954 const static struct method imap =
956 "IMAP", /* Internet Message Access Protocol */
960 #else /* INET6_ENABLE */
961 143, /* standard IMAP2bis/IMAP4 port */
962 993, /* ssl IMAP2bis/IMAP4 port */
963 #endif /* INET6_ENABLE */
964 TRUE, /* this is a tagged protocol */
965 FALSE, /* no message delimiter */
966 imap_ok, /* parse command response */
967 imap_getauth, /* get authorization */
968 imap_getrange, /* query range of messages */
969 imap_getsizes, /* get sizes of messages (used for ESMTP SIZE option) */
970 imap_is_old, /* no UID check */
971 imap_fetch_headers, /* request given message headers */
972 imap_fetch_body, /* request given message body */
973 imap_trail, /* eat message trailer */
974 imap_delete, /* delete the message */
975 imap_logout, /* expunge and exit */
976 TRUE, /* yes, we can re-poll */
979 int doIMAP(struct query *ctl)
980 /* retrieve messages using IMAP Version 2bis or Version 4 */
982 return(do_protocol(ctl, &imap));
985 /* imap.c ends here */