* Eliminated the sock_puts_crlf() function and ensured that all SMTP client
authorArt Cancro <ajc@citadel.org>
Fri, 16 Nov 2001 04:43:13 +0000 (04:43 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 16 Nov 2001 04:43:13 +0000 (04:43 +0000)
  commands are sent out using a single sock_write() call.  There are broken
  SMTP server implementations that can't handle SMTP commands split across
  multiple writes.  (Thanks to Andru Luvisi and Ben Mehlman for the idea.)

citadel/ChangeLog
citadel/clientsocket.c
citadel/clientsocket.h
citadel/serv_smtp.c

index fb9a7840f862b6f2de00b0fb80b5f184450c2ecf..02d05150279aa6c746a9d9e8bfbff1997a2d7194 100644 (file)
@@ -1,4 +1,10 @@
  $Log$
+ Revision 580.76  2001/11/16 04:43:12  ajc
+ * Eliminated the sock_puts_crlf() function and ensured that all SMTP client
+   commands are sent out using a single sock_write() call.  There are broken
+   SMTP server implementations that can't handle SMTP commands split across
+   multiple writes.  (Thanks to Andru Luvisi and Ben Mehlman for the idea.)
+
  Revision 580.75  2001/11/15 04:11:30  ajc
  * hack.doc: updated to reflect Cit86Net compatibility fields removed from the
    file format (since we dumbed down the gateway software)
@@ -2862,3 +2868,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
+
index 286659aef946e8e4787c3253972ae740d196a51c..f096cdb345d26dfd0ad664f105525d42e0a14e34 100644 (file)
@@ -201,19 +201,3 @@ int sock_puts(int sock, char *buf)
        if (j<0) return(j);
        return(i+j);
 }
-
-
-/*
- * sock_puts_crlf() - same as sock_puts() but ends line with CRLF, not LF
- * Returns the number of bytes written, or -1 for error.
- */
-int sock_puts_crlf(int sock, char *buf)
-{
-       int i, j;
-
-       i = sock_write(sock, buf, strlen(buf));
-       if (i<0) return(i);
-       j = sock_write(sock, "\r\n", 2);
-       if (j<0) return(j);
-       return(i+j);
-}
index cdcae4489a72c748826243b9aac34ecef376096e..6bbe88db57eadd2aefe7908bea23004e874d2cf5 100644 (file)
@@ -10,7 +10,6 @@ int sock_write(int sock, char *buf, int nbytes);
 int ml_sock_gets(int sock, char *buf);
 int sock_gets(int sock, char *buf);
 int sock_puts(int sock, char *buf);
-int sock_puts_crlf(int sock, char *buf);
 
 /* 
  * This looks dumb, but it's being done for future portability
index 53a54881b1feb5f6c18adf80fd34f35db05e9673..e3724487c4fc67ea7fb6f7f27c8ae01034bdaf81 100644 (file)
@@ -923,12 +923,12 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum)
        /* At this point we know we are talking to a real SMTP server */
 
        /* Do a HELO command */
-       snprintf(buf, sizeof buf, "HELO %s", config.c_fqdn);
-       lprintf(9, ">%s\n", buf);
-       sock_puts_crlf(sock, buf);
+       snprintf(buf, sizeof buf, "HELO %s\r\n", config.c_fqdn);
+       lprintf(9, ">%s", buf);
+       sock_write(sock, buf, strlen(buf));
        if (ml_sock_gets(sock, buf) < 0) {
                *status = 4;
-               strcpy(dsn, "Connection broken during SMTP conversation");
+               strcpy(dsn, "Connection broken during SMTP HELO");
                goto bail;
        }
        lprintf(9, "<%s\n", buf);
@@ -947,12 +947,12 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum)
 
 
        /* HELO succeeded, now try the MAIL From: command */
-       snprintf(buf, sizeof buf, "MAIL From: <%s>", mailfrom);
-       lprintf(9, ">%s\n", buf);
-       sock_puts_crlf(sock, buf);
+       snprintf(buf, sizeof buf, "MAIL From: <%s>\r\n", mailfrom);
+       lprintf(9, ">%s", buf);
+       sock_write(sock, buf, strlen(buf));
        if (ml_sock_gets(sock, buf) < 0) {
                *status = 4;
-               strcpy(dsn, "Connection broken during SMTP conversation");
+               strcpy(dsn, "Connection broken during SMTP MAIL");
                goto bail;
        }
        lprintf(9, "<%s\n", buf);
@@ -971,12 +971,12 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum)
 
 
        /* MAIL succeeded, now try the RCPT To: command */
-       snprintf(buf, sizeof buf, "RCPT To: <%s>", addr);
-       lprintf(9, ">%s\n", buf);
-       sock_puts_crlf(sock, buf);
+       snprintf(buf, sizeof buf, "RCPT To: <%s>\r\n", addr);
+       lprintf(9, ">%s", buf);
+       sock_write(sock, buf, strlen(buf));
        if (ml_sock_gets(sock, buf) < 0) {
                *status = 4;
-               strcpy(dsn, "Connection broken during SMTP conversation");
+               strcpy(dsn, "Connection broken during SMTP RCPT");
                goto bail;
        }
        lprintf(9, "<%s\n", buf);
@@ -996,10 +996,10 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum)
 
        /* RCPT succeeded, now try the DATA command */
        lprintf(9, ">DATA\n");
-       sock_puts_crlf(sock, "DATA");
+       sock_write(sock, "DATA\r\n", 6);
        if (ml_sock_gets(sock, buf) < 0) {
                *status = 4;
-               strcpy(dsn, "Connection broken during SMTP conversation");
+               strcpy(dsn, "Connection broken during SMTP DATA");
                goto bail;
        }
        lprintf(9, "<%s\n", buf);
@@ -1034,7 +1034,7 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum)
        sock_write(sock, ".\r\n", 3);
        if (ml_sock_gets(sock, buf) < 0) {
                *status = 4;
-               strcpy(dsn, "Connection broken during SMTP conversation");
+               strcpy(dsn, "Connection broken during SMTP message transmit");
                goto bail;
        }
        lprintf(9, "%s\n", buf);
@@ -1056,7 +1056,7 @@ void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum)
        *status = 2;
 
        lprintf(9, ">QUIT\n");
-       sock_puts_crlf(sock, "QUIT");
+       sock_write(sock, "QUIT\r\n", 6);
        ml_sock_gets(sock, buf);
        lprintf(9, "<%s\n", buf);