aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--driver.c6
-rw-r--r--smtp.c63
-rw-r--r--smtp.h1
4 files changed, 45 insertions, 28 deletions
diff --git a/NEWS b/NEWS
index 8ed9085a..e2769764 100644
--- a/NEWS
+++ b/NEWS
@@ -53,6 +53,9 @@ fetchmail-1.0 (Mon Sep 23 19:54:01 EDT 1996):
* Name change (it ain't just for POP3 any more).
+* Stricter RFC822 conformance, so SMTP to qmail works. Thanks to
+ Cameron MacPherson <unsound@oz.net> for these changes.
+
popclient-3.2 (Mon Sep 23 13:29:46 EDT 1996):
* RPOP support (coded at a user's request but untested).
diff --git a/driver.c b/driver.c
index 6ab0dd0f..177f67b9 100644
--- a/driver.c
+++ b/driver.c
@@ -223,8 +223,10 @@ closeUp:
if (closeuserfolder(mboxfd) < 0 && ok == 0)
ok = PS_IOERR;
}
- else if (queryctl->output == TO_SMTP && mboxfd > 0)
+ else if (queryctl->output == TO_SMTP && mboxfd > 0) {
+ SMTP_quit(mboxfd);
close(mboxfd);
+ }
if (ok == PS_IOERR || ok == PS_SOCKET)
perror("do_protocol: cleanUp");
@@ -598,7 +600,7 @@ int rewrite;
if (delimited && *bufp == 0)
break; /* end of message */
}
- strcat(bufp,"\n");
+ strcat(bufp, output == TO_SMTP && !inheaders ? "\r\n" : "\n");
if (inheaders)
{
diff --git a/smtp.c b/smtp.c
index d96e3248..657d9373 100644
--- a/smtp.c
+++ b/smtp.c
@@ -7,6 +7,7 @@
module: smtp.c
project: fetchmail
programmer: Harry Hochheiser
+ cleaned up and made rfc821 compliant by Cameron MacPherson
description: Handling of SMTP connections, and processing of mail
to be forwarded via SMTP connections.
@@ -34,17 +35,14 @@
int SMTP_helo(int socket,char *host)
{
int ok;
- char buf[SMTPBUFSIZE+1];
- sprintf(buf,"HELO %s",host);
- SockPuts(socket, buf);
+ SockPrintf(socket,"HELO %s\r\n", host);
if (outlevel == O_VERBOSE)
- fprintf(stderr, "SMTP> %s\n", buf);
- ok = SMTP_ok(socket,buf);
+ fprintf(stderr, "SMTP> HELO %s\n", host);
+ ok = SMTP_ok(socket,NULL);
return ok;
}
-
/*********************************************************************
function: SMTP_from
description: Send a "MAIL FROM:" message to the SMTP server.
@@ -61,17 +59,15 @@ int SMTP_helo(int socket,char *host)
*********************************************************************/
int SMTP_from(int socket, char *from)
{
- char buf[SMTPBUFSIZE+1]; /* it's as good as size as any... */
int ok;
- SockPrintf(socket, "MAIL FROM: %s\n", from);
- if (outlevel == O_VERBOSE)
- fprintf(stderr, "SMTP> MAIL FROM: %s\n", from);
- ok = SMTP_ok(socket,buf);
+ SockPrintf(socket,"MAIL FROM:<%s>\r\n", from);
+ if (outlevel == O_VERBOSE)
+ fprintf(stderr, "SMTP> MAIL FROM:<%s>\n", from);
+ ok = SMTP_ok(socket,NULL);
return ok;
}
-
/*********************************************************************
function: SMTP_rcpt
description: Send a "RCPT TO:" message to the SMTP server.
@@ -86,18 +82,15 @@ int SMTP_from(int socket, char *from)
*********************************************************************/
int SMTP_rcpt(int socket,char *to)
{
- char buf[SMTPBUFSIZE+1]; /* it's as good as size as any... */
int ok;
- SockPrintf(socket, "RCPT TO: %s\n", to);
+ SockPrintf(socket,"RCPT TO:<%s>\r\n", to);
if (outlevel == O_VERBOSE)
- fprintf(stderr, "SMTP> RCPT TO: %s\n", to);
- ok = SMTP_ok(socket,buf);
-
+ fprintf(stderr, "SMTP> RCPT TO:<%s>\n", to);
+ ok = SMTP_ok(socket,NULL);
return ok;
}
-
/*********************************************************************
function: SMTP_data
description: Send a "DATA" message to the SMTP server.
@@ -110,11 +103,31 @@ int SMTP_data(int socket)
{
int ok;
- SockPrintf(socket,"DATA\n");
+ SockPrintf(socket,"DATA\r\n");
if (outlevel == O_VERBOSE)
fprintf(stderr, "SMTP> DATA\n");
- ok = SMTP_ok(socket, NULL);
-
+ ok = SMTP_ok(socket,NULL);
+ return ok;
+}
+
+/*********************************************************************
+ function: SMTP_quit
+ description: Send a "QUIT" message to the SMTP server.
+
+ arguments:
+ socket TCP/IP socket for connection to SMTP
+
+ return value: Result of SMTP_OK: based on codes in fetchmail.h.
+
+ *********************************************************************/
+int SMTP_quit(int socket)
+{
+ int ok;
+
+ SockPrintf(socket,"QUIT\r\n");
+ if (outlevel == O_VERBOSE)
+ fprintf(stderr, "SMTP> QUIT\n");
+ ok = SMTP_ok(socket,NULL);
return ok;
}
@@ -132,7 +145,7 @@ int SMTP_eom(int socket)
{
int ok;
- SockPuts(socket,".");
+ SockPrintf(socket,".\r\n");
if (outlevel == O_VERBOSE)
fprintf(stderr, "SMTP> (EOM)\n");
ok = SMTP_ok(socket,NULL);
@@ -141,7 +154,7 @@ int SMTP_eom(int socket)
/*********************************************************************
function: SMTP_rset
- description: Send an "RSET" message to the SMTP server.
+ description: Send a "RSET" message to the SMTP server.
arguments:
socket TCP/IP socket for connection to SMTP
@@ -149,7 +162,7 @@ int SMTP_eom(int socket)
*********************************************************************/
void SMTP_rset(int socket)
{
- SockPrintf(socket,"RSET\n");
+ SockPrintf(socket,"RSET\r\n");
if (outlevel == O_VERBOSE)
fprintf(stderr, "SMTP> RSET\n");
}
@@ -193,7 +206,6 @@ static int SMTP_check(int socket,char *argbuf)
int SMTP_ok(int socket,char *argbuf)
{
int ok;
- char buf[SMTPBUFSIZE+1];
/* I can tell that the SMTP server connection is ok if I can read a
status message that starts with "1xx" ,"2xx" or "3xx".
@@ -230,4 +242,3 @@ int SMTP_Gets(int socket,char *buf,int sz)
{
return read(socket,buf,sz);
}
-
diff --git a/smtp.h b/smtp.h
index 10a3bb7d..7ee1893d 100644
--- a/smtp.h
+++ b/smtp.h
@@ -26,6 +26,7 @@ int SMTP_from(int socket,char *from);
int SMTP_rcpt(int socket,char *to);
int SMTP_data(int socket);
int SMTP_eom(int socket);
+int SMTP_quit(int socket);
int SMTP_ok(int socket,char *argbuf);
int SMTP_Gets(int socket,char *buf,int sz);
void SMTP_rset(int socket);