aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.in4
-rw-r--r--NEWS1
-rw-r--r--driver.c4
-rw-r--r--fetchmail.c1
-rw-r--r--smtp.c56
-rw-r--r--smtp.h2
6 files changed, 33 insertions, 35 deletions
diff --git a/Makefile.in b/Makefile.in
index a59a340e..b865b16a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -3,8 +3,8 @@
# If you're running QNX, we can't assume a working autoconf.
# So just uncomment all the lines marked QNX.
-VERS=1.9
-PL=9
+VERS=2.0
+PL=0
# Ultrix 2.2 make doesn't expand the value of VPATH.
srcdir = @srcdir@
diff --git a/NEWS b/NEWS
index 7a1248c0..fb2d07a4 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ fetchmail-2.0 ():
* Fix typo in setitimer call setup that caused obscure bugs under FreeBSD.
* Handle Apparently-To.
+* Include Cameron McPherson's patch for handling multi-line SMTP responses.
pl 1.9.9 (Mon Nov 11 10:40:14 EST 1996):
* Accept Resent-From & Apparently-From a la RFC822.
diff --git a/driver.c b/driver.c
index fa5b0cac..42f505ee 100644
--- a/driver.c
+++ b/driver.c
@@ -242,7 +242,7 @@ static FILE *smtp_open(struct query *ctl)
{
if ((ctl->smtp_sockfp = Socket(ctl->smtphost, SMTP_PORT)) == (FILE *)NULL)
return((FILE *)NULL);
- else if (SMTP_ok(ctl->smtp_sockfp, NULL) != SM_OK
+ else if (SMTP_ok(ctl->smtp_sockfp) != SM_OK
|| SMTP_helo(ctl->smtp_sockfp, ctl->servername) != SM_OK)
{
fclose(ctl->smtp_sockfp);
@@ -436,7 +436,7 @@ struct query *ctl; /* query control record */
{
char *ap;
- if (ctl->mda[0] == '\0' && ((sinkfp = smtp_open(ctl)) < 0))
+ if (ctl->mda[0] == '\0' && ((sinkfp = smtp_open(ctl)) == NULL))
{
free_uid_list(&xmit_names);
fprintf(stderr, "fetchmail: SMTP connect failed\n");
diff --git a/fetchmail.c b/fetchmail.c
index 3cfe3466..b10da556 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -357,6 +357,7 @@ int main (int argc, char **argv)
for (ctl = querylist; ctl; ctl = ctl->next)
if (ctl->smtp_sockfp)
{
+ SMTP_quit(ctl->smtp_sockfp);
fclose(ctl->smtp_sockfp);
ctl->smtp_sockfp = (FILE *)NULL;
}
diff --git a/smtp.c b/smtp.c
index cab2ef6c..77ced235 100644
--- a/smtp.c
+++ b/smtp.c
@@ -26,7 +26,7 @@ int SMTP_helo(FILE *sockfp,char *host)
SockPrintf(sockfp,"HELO %s\r\n", host);
if (outlevel == O_VERBOSE)
fprintf(stderr, "SMTP> HELO %s\n", host);
- ok = SMTP_ok(sockfp,NULL);
+ ok = SMTP_ok(sockfp);
return ok;
}
@@ -38,7 +38,7 @@ int SMTP_from(FILE *sockfp, char *from)
SockPrintf(sockfp,"MAIL FROM:<%s>\r\n", from);
if (outlevel == O_VERBOSE)
fprintf(stderr, "SMTP> MAIL FROM:<%s>\n", from);
- ok = SMTP_ok(sockfp,NULL);
+ ok = SMTP_ok(sockfp);
return ok;
}
@@ -50,7 +50,7 @@ int SMTP_rcpt(FILE *sockfp, char *to)
SockPrintf(sockfp,"RCPT TO:<%s>\r\n", to);
if (outlevel == O_VERBOSE)
fprintf(stderr, "SMTP> RCPT TO:<%s>\n", to);
- ok = SMTP_ok(sockfp,NULL);
+ ok = SMTP_ok(sockfp);
return ok;
}
@@ -62,7 +62,7 @@ int SMTP_data(FILE *sockfp)
SockPrintf(sockfp,"DATA\r\n");
if (outlevel == O_VERBOSE)
fprintf(stderr, "SMTP> DATA\n");
- ok = SMTP_ok(sockfp,NULL);
+ ok = SMTP_ok(sockfp);
return ok;
}
@@ -74,7 +74,7 @@ int SMTP_quit(FILE *sockfp)
SockPrintf(sockfp,"QUIT\r\n");
if (outlevel == O_VERBOSE)
fprintf(stderr, "SMTP> QUIT\n");
- ok = SMTP_ok(sockfp,NULL);
+ ok = SMTP_ok(sockfp);
return ok;
}
@@ -86,7 +86,7 @@ int SMTP_eom(FILE *sockfp)
SockPrintf(sockfp,".\r\n");
if (outlevel == O_VERBOSE)
fprintf(stderr, "SMTP>. (EOM)\n");
- ok = SMTP_ok(sockfp,NULL);
+ ok = SMTP_ok(sockfp);
return ok;
}
@@ -98,33 +98,29 @@ void SMTP_rset(FILE *sockfp)
fprintf(stderr, "SMTP> RSET\n");
}
-static int SMTP_check(FILE *sockfp,char *argbuf)
+
+static int SMTP_check(FILE *sockfp)
/* returns status of SMTP connection */
{
- int ok;
- char buf[SMTPBUFSIZE];
+ int n;
+ char buf[SMTPBUFSIZE];
- if ((ok = SockGets(buf, sizeof(buf)-1, sockfp)) > 0) {
- buf[ok] = '\0';
- if (outlevel == O_VERBOSE)
- fprintf(stderr, "SMTP< %s\n", buf);
- if (argbuf)
- strcpy(argbuf,buf);
- if (buf[0] == '1' || buf[0] == '2' || buf[0] == '3')
- ok = SM_OK;
- else
- ok = SM_ERROR;
- }
- else
- {
- if (outlevel == O_VERBOSE)
- fprintf(stderr, "SMTP< (read failed)\n");
- ok = SM_UNRECOVERABLE;
- }
- return (ok);
+ while ((n = SockGets(buf, sizeof(buf)-1, sockfp)) > 0)
+ {
+ if (n < 4)
+ return SM_ERROR;
+ buf[n] = '\0';
+ if (outlevel == O_VERBOSE)
+ fprintf(stderr, "SMTP< %s\n", buf);
+ if ((buf[0] == '1' || buf[0] == '2' || buf[0] == '3') && buf[3] == ' ')
+ return SM_OK;
+ else if (buf[3] != '-')
+ return SM_ERROR;
+ }
+ return SM_UNRECOVERABLE;
}
-int SMTP_ok(FILE *sockfp,char *argbuf)
+int SMTP_ok(FILE *sockfp)
/* accepts SMTP response, returns status of SMTP connection */
{
int ok;
@@ -138,11 +134,11 @@ int SMTP_ok(FILE *sockfp,char *argbuf)
*/
- ok = SMTP_check(sockfp,argbuf);
+ ok = SMTP_check(sockfp);
if (ok == SM_ERROR) /* if we got an error, */
{
SMTP_rset(sockfp);
- ok = SMTP_check(sockfp,argbuf); /* how does it look now ? */
+ ok = SMTP_check(sockfp); /* how does it look now ? */
if (ok == SM_OK)
ok = SM_ERROR; /* It's just a simple error, for*/
/* the current message */
diff --git a/smtp.h b/smtp.h
index 96b3e44b..d673ec93 100644
--- a/smtp.h
+++ b/smtp.h
@@ -20,7 +20,7 @@ int SMTP_rcpt(FILE *sockfp,char *to);
int SMTP_data(FILE *sockfp);
int SMTP_eom(FILE *sockfp);
int SMTP_quit(FILE *sockfp);
-int SMTP_ok(FILE *sockfp,char *argbuf);
+int SMTP_ok(FILE *sockfp);
void SMTP_rset(FILE *sockfp);
#endif