diff -Naur fetchmail-5.9.6.orig/driver.c fetchmail-5.9.6/driver.c --- fetchmail-5.9.6.orig/driver.c Mon Jan 28 11:34:27 2002 +++ fetchmail-5.9.6/driver.c Mon Jan 28 11:44:14 2002 @@ -788,7 +788,7 @@ /* try to clean up all streams */ release_sink(ctl); - smtp_close(ctl); + smtp_close(ctl, 0); if (mailserver_socket != -1) { cleanupSockClose(mailserver_socket); mailserver_socket = -1; diff -Naur fetchmail-5.9.6.orig/fetchmail.c fetchmail-5.9.6/fetchmail.c --- fetchmail-5.9.6.orig/fetchmail.c Fri Nov 9 00:03:45 2001 +++ fetchmail-5.9.6/fetchmail.c Mon Jan 28 11:44:10 2002 @@ -1202,10 +1202,7 @@ { /* don't send QUIT for ODMR case because we're acting as a proxy between the SMTP server and client. */ - if (ctl->server.protocol != P_ODMR) - SMTP_quit(ctl->smtp_socket); - SockClose(ctl->smtp_socket); - ctl->smtp_socket = -1; + smtp_close(ctl, ctl->server.protocol != P_ODMR); } } diff -Naur fetchmail-5.9.6.orig/fetchmail.h fetchmail-5.9.6/fetchmail.h --- fetchmail-5.9.6.orig/fetchmail.h Mon Jan 28 11:34:27 2002 +++ fetchmail-5.9.6/fetchmail.h Mon Jan 28 11:44:22 2002 @@ -462,7 +462,7 @@ int interruptible_idle(int interval); /* sink.c: forwarding */ -void smtp_close(struct query *); +void smtp_close(struct query *, int); int smtp_open(struct query *); int stuffline(struct query *, char *); int open_sink(struct query*, struct msgblk *, int*, int*); diff -Naur fetchmail-5.9.6.orig/imap.c fetchmail-5.9.6/imap.c --- fetchmail-5.9.6.orig/imap.c Mon Jan 28 11:34:27 2002 +++ fetchmail-5.9.6/imap.c Mon Jan 28 11:44:16 2002 @@ -508,7 +508,7 @@ /* this is a while loop because imap_idle() might return on other * mailbox changes also */ while (recentcount == 0 && do_idle) { - smtp_close(ctl); + smtp_close(ctl, 1); ok = imap_idle(sock); if (ok) { diff -Naur fetchmail-5.9.6.orig/sink.c fetchmail-5.9.6/sink.c --- fetchmail-5.9.6.orig/sink.c Mon Jan 28 11:34:27 2002 +++ fetchmail-5.9.6/sink.c Mon Jan 28 11:44:18 2002 @@ -46,11 +46,13 @@ /* makes the open_sink()/close_sink() pair non-reentrant */ static int lmtp_responses; -void smtp_close(struct query *ctl) +void smtp_close(struct query *ctl, int sayquit) /* close the socket to SMTP server */ { if (ctl->smtp_socket != -1) { + if (sayquit) + SMTP_quit(ctl->smtp_socket); SockClose(ctl->smtp_socket); ctl->smtp_socket = -1; } @@ -64,7 +66,7 @@ /* maybe it's time to close the socket in order to force delivery */ if (NUM_NONZERO(ctl->batchlimit) && ++batchcount == ctl->batchlimit) - smtp_close(ctl); + smtp_close(ctl, 1); /* if no socket to any SMTP host is already set up, try to open one */ if (ctl->smtp_socket == -1) @@ -153,7 +155,7 @@ * RFC 1869 warns that some listeners hang up on a failed EHLO, * so it's safest not to assume the socket will still be good. */ - smtp_close(ctl); + smtp_close(ctl, 0); /* if opening for ESMTP failed, try SMTP */ if ((ctl->smtp_socket = SockOpen(parsed_host,portnum,NULL, @@ -164,7 +166,7 @@ SMTP_helo(ctl->smtp_socket, id_me) == SM_OK) break; /* success */ - smtp_close(ctl); + smtp_close(ctl, 0); } set_timeout(0); phase = oldphase;