]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_smtp.c
* Add specific error codes for every command on the wire protocol, so that
[citadel.git] / citadel / serv_smtp.c
index e2d1b93b06f51be10adc02bbf8b13bf0147c00c5..56408ca6e245398c5354293b7e83a1b0ab203883 100644 (file)
@@ -1,13 +1,23 @@
 /*
  * $Id$
  *
- * This module implements the following protocols for the Citadel system:
+ * This module is an SMTP and ESMTP implementation for the Citadel system.
+ * It is compliant with all of the following:
  *
- * RFC 821 (Simple Mail Transfer Protocol)
- * RFC 1854 (command pipelining)
- * RFC 1869 (Extended Simple Mail Transfer Protocol)
- * RFC 2033 (Local Mail Transfer Protocol)
- * RFC 2034 (enhanced status codes)
+ * RFC  821 - Simple Mail Transfer Protocol
+ * RFC  876 - Survey of SMTP Implementations
+ * RFC 1047 - Duplicate messages and SMTP
+ * RFC 1854 - command pipelining
+ * RFC 1869 - Extended Simple Mail Transfer Protocol
+ * RFC 1870 - SMTP Service Extension for Message Size Declaration
+ * RFC 1893 - Enhanced Mail System Status Codes
+ * RFC 2033 - Local Mail Transfer Protocol
+ * RFC 2034 - SMTP Service Extension for Returning Enhanced Error Codes
+ * RFC 2197 - SMTP Service Extension for Command Pipelining
+ * RFC 2554 - SMTP Service Extension for Authentication
+ * RFC 2821 - Simple Mail Transfer Protocol
+ * RFC 2822 - Internet Message Format
+ * RFC 2920 - SMTP Service Extension for Command Pipelining
  *
  */
 
@@ -151,10 +161,23 @@ void smtp_hello(char *argbuf, int which_command) {
        }
 
        if (which_command == 0) {
-               cprintf("250 Greetings and joyous salutations.\r\n");
+               cprintf("250 Hello %s (%s [%s])\r\n",
+                       SMTP->helo_node,
+                       CC->cs_host,
+                       CC->cs_addr
+               );
        }
        else {
-               cprintf("250-Greetings and joyous salutations.\r\n");
+               if (which_command == 1) {
+                       cprintf("250-Hello %s (%s [%s])\r\n",
+                               SMTP->helo_node,
+                               CC->cs_host,
+                               CC->cs_addr
+                       );
+               }
+               else {
+                       cprintf("250-Greetings and joyous salutations.\r\n");
+               }
                cprintf("250-HELP\r\n");
                cprintf("250-SIZE %ld\r\n", config.c_maxmsglen);
                cprintf("250-PIPELINING\r\n");
@@ -164,6 +187,7 @@ void smtp_hello(char *argbuf, int which_command) {
 }
 
 
+
 /*
  * Implement HELP command.
  */
@@ -220,7 +244,7 @@ void smtp_get_pass(char *argbuf) {
                CC->cs_flags &= ~CS_STEALTH;
        }
        else {
-               cprintf("500 5.7.0 Authentication failed.\r\n");
+               cprintf("535 5.7.0 Authentication failed.\r\n");
        }
        SMTP->command_state = smtp_command;
 }
@@ -233,7 +257,7 @@ void smtp_auth(char *argbuf) {
        char buf[SIZ];
 
        if (strncasecmp(argbuf, "login", 5) ) {
-               cprintf("550 5.7.4 We only support LOGIN authentication.\r\n");
+               cprintf("504 5.7.4 We only support LOGIN authentication.\r\n");
                return;
        }
 
@@ -336,6 +360,15 @@ void smtp_expn(char *argbuf) {
  * be sure to phree() them first!
  */
 void smtp_rset(void) {
+       int is_lmtp;
+
+       /*
+        * Our entire SMTP state is discarded when a RSET command is issued,
+        * but we need to preserve this one little piece of information, so
+        * we save it for later.
+        */
+       is_lmtp = SMTP->is_lmtp;
+
        memset(SMTP, 0, sizeof(struct citsmtp));
 
        /*
@@ -349,6 +382,11 @@ void smtp_rset(void) {
         * }
         */
 
+       /*
+        * Reinstate this little piece of information we saved (see above).
+        */
+       SMTP->is_lmtp = is_lmtp;
+
        cprintf("250 2.0.0 Zap!\r\n");
 }
 
@@ -1444,7 +1482,7 @@ void cmd_smtp(char *argbuf) {
        }
 
        else {
-               cprintf("%d Invalid command.\n", ERROR+ILLEGAL_VALUE);
+               cprintf("%d Invalid command.\n", ERROR + ILLEGAL_VALUE);
        }
 
 }