* SMTP delivery is working but still *very* rough.
authorArt Cancro <ajc@citadel.org>
Wed, 26 Jan 2000 02:41:28 +0000 (02:41 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 26 Jan 2000 02:41:28 +0000 (02:41 +0000)
citadel/ChangeLog
citadel/serv_smtp.c
citadel/sysconfig.h

index 05689b35974bef8bddc3b4b6cfbf1057c6a508db..af1a9f129694e414e40aafb8e8283cc0ca9765bb 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 1.453  2000/01/26 02:41:27  ajc
+* SMTP delivery is working but still *very* rough.
+
 Revision 1.452  2000/01/25 04:45:50  ajc
 * Wrote enough of the SMTP sender to get Patriot drooling over it, but not
   enough to complete the transmission of mail.
@@ -1590,3 +1593,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
+
index fb01d6329c5994ed929bf0125de068091ef14f6c..849e4a2fe3468fcb38abfc6a1610691e56ca5ed3 100644 (file)
@@ -677,7 +677,8 @@ void smtp_command_loop(void) {
  * Called by smtp_do_procmsg() to attempt delivery to one SMTP host
  *
  */
-void smtp_try(char *key, char *addr, int *status, char *dsn) {
+void smtp_try(char *key, char *addr, int *status, char *dsn, long msgnum)
+{
        char buf[256];
        int sock = (-1);
        char mxhosts[1024];
@@ -722,7 +723,7 @@ void smtp_try(char *key, char *addr, int *status, char *dsn) {
        }
        lprintf(9, "%s\n", buf);
        if (buf[0] != '2') {
-               if (buf[0] == '3') {
+               if (buf[0] == '4') {
                        *status = 3;
                        strcpy(dsn, &buf[4]);
                        sock_close(sock);
@@ -749,7 +750,33 @@ void smtp_try(char *key, char *addr, int *status, char *dsn) {
        }
        lprintf(9, "%s\n", buf);
        if (buf[0] != '2') {
-               if (buf[0] == '3') {
+               if (buf[0] == '4') {
+                       *status = 3;
+                       strcpy(dsn, &buf[4]);
+                       sock_close(sock);
+                       return;
+               }
+               else {
+                       *status = 5;
+                       strcpy(dsn, &buf[4]);
+                       sock_close(sock);
+                       return;
+               }
+       }
+
+
+       /* HELO succeeded, now try the MAIL From: command */
+       sprintf(buf, "MAIL From: ajc@uncnsrd.mt-kisco.ny.us"); /* FIX */
+       sock_puts(sock, buf);
+       if (sock_gets(sock, buf) < 0) {
+               *status = 3;
+               strcpy(dsn, "Connection broken during SMTP conversation");
+               sock_close(sock);
+               return;
+       }
+       lprintf(9, "%s\n", buf);
+       if (buf[0] != '2') {
+               if (buf[0] == '4') {
                        *status = 3;
                        strcpy(dsn, &buf[4]);
                        sock_close(sock);
@@ -763,15 +790,90 @@ void smtp_try(char *key, char *addr, int *status, char *dsn) {
                }
        }
 
+
+       /* MAIL succeeded, now try the RCPT To: command */
+       sprintf(buf, "RCPT To: %s", addr);
+       sock_puts(sock, buf);
+       if (sock_gets(sock, buf) < 0) {
+               *status = 3;
+               strcpy(dsn, "Connection broken during SMTP conversation");
+               sock_close(sock);
+               return;
+       }
+       lprintf(9, "%s\n", buf);
+       if (buf[0] != '2') {
+               if (buf[0] == '4') {
+                       *status = 3;
+                       strcpy(dsn, &buf[4]);
+                       sock_close(sock);
+                       return;
+               }
+               else {
+                       *status = 5;
+                       strcpy(dsn, &buf[4]);
+                       sock_close(sock);
+                       return;
+               }
+       }
+
+
+       /* RCPT succeeded, now try the DATA command */
+       sock_puts(sock, "DATA");
+       if (sock_gets(sock, buf) < 0) {
+               *status = 3;
+               strcpy(dsn, "Connection broken during SMTP conversation");
+               sock_close(sock);
+               return;
+       }
+       lprintf(9, "%s\n", buf);
+       if (buf[0] != '3') {
+               if (buf[0] == '4') {
+                       *status = 3;
+                       strcpy(dsn, &buf[4]);
+                       sock_close(sock);
+                       return;
+               }
+               else {
+                       *status = 5;
+                       strcpy(dsn, &buf[4]);
+                       sock_close(sock);
+                       return;
+               }
+       }
+
+       /* If we reach this point, the server is expecting data */
+       CtdlOutputMsg(msgnum, MT_RFC822, 0, 0, NULL, sock, 1);
+       sock_puts(sock, ".");
+       if (sock_gets(sock, buf) < 0) {
+               *status = 3;
+               strcpy(dsn, "Connection broken during SMTP conversation");
+               sock_close(sock);
+               return;
+       }
+       lprintf(9, "%s\n", buf);
+       if (buf[0] != '2') {
+               if (buf[0] == '4') {
+                       *status = 3;
+                       strcpy(dsn, &buf[4]);
+                       sock_close(sock);
+                       return;
+               }
+               else {
+                       *status = 5;
+                       strcpy(dsn, &buf[4]);
+                       sock_close(sock);
+                       return;
+               }
+       }
+
+       /* We did it! */
+       strcpy(dsn, &buf[4]);
+       *status = 2;
+
        sock_puts(sock, "QUIT");
        sock_gets(sock, buf);
        lprintf(9, "%s\n", buf);
        sock_close(sock);
-
-       /* temporary hook to make things not go kerblooie */
-       *status = 3;
-       strcpy(dsn, "smtp_try() is not finished yet");
-       /*                                                */
 }
 
 
@@ -827,7 +929,7 @@ void smtp_do_procmsg(long msgnum) {
        }
 
        if (text_msgid < 0L) {
-               lprintf(3, "SMTP: no 'msgid' directive found!\n", msgnum);
+               lprintf(3, "SMTP: no 'msgid' directive found!\n");
                phree(instr);
                return;
        }
@@ -849,7 +951,7 @@ void smtp_do_procmsg(long msgnum) {
                        --i;
                        --lines;
                        lprintf(9, "SMTP: Trying <%s>\n", addr);
-                       smtp_try(key, addr, &status, dsn);
+                       smtp_try(key, addr, &status, dsn, text_msgid);
                        if (status != 2) {
                                if (results == NULL) {
                                        results = mallok(1024);
index 198f7e557144b00ffd2536dd8a8d17742de1fcee..3ce4597f87e514ffb5fca948d6931d33a2f09ebd 100644 (file)
@@ -83,8 +83,8 @@
  * These define what port to listen on for various services.
  * FIX ... put this in a programmable config somewhere
  */
-#define POP3_PORT              110
-#define SMTP_PORT              25
+#define POP3_PORT              1110
+#define SMTP_PORT              2525
 
 
 /*