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.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)
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)
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
if (j<0) return(j);
return(i+j);
}
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);
-}
int ml_sock_gets(int sock, char *buf);
int sock_gets(int sock, char *buf);
int sock_puts(int sock, char *buf);
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
/*
* This looks dumb, but it's being done for future portability
/* At this point we know we are talking to a real SMTP server */
/* Do a HELO command */
/* 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;
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);
goto bail;
}
lprintf(9, "<%s\n", buf);
/* HELO succeeded, now try the MAIL From: command */
/* 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;
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);
goto bail;
}
lprintf(9, "<%s\n", buf);
/* MAIL succeeded, now try the RCPT To: command */
/* 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;
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);
goto bail;
}
lprintf(9, "<%s\n", buf);
/* RCPT succeeded, now try the DATA command */
lprintf(9, ">DATA\n");
/* 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;
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);
goto bail;
}
lprintf(9, "<%s\n", buf);
sock_write(sock, ".\r\n", 3);
if (ml_sock_gets(sock, buf) < 0) {
*status = 4;
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);
goto bail;
}
lprintf(9, "%s\n", buf);
*status = 2;
lprintf(9, ">QUIT\n");
*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);
ml_sock_gets(sock, buf);
lprintf(9, "<%s\n", buf);