]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/smtp/serv_smtp.c
* give message sender in while evaluating the recipient...
[citadel.git] / citadel / modules / smtp / serv_smtp.c
index 77b2618ea055df4b82f474e6db1205d138ba1540..507d44d6d68e89a09aa566cf5cb6ede15595b7f2 100644 (file)
@@ -483,7 +483,13 @@ void smtp_data_clear(void) {
        SMTP->message_originated_locally = 0;
 }
 
+const char *smtp_get_Recipients(void)
+{
+       if (SMTP == NULL)
+               return NULL;
+       else return SMTP->from;
 
+}
 
 /*
  * Implements the "MAIL From:" command
@@ -598,7 +604,9 @@ void smtp_rcpt(char *argbuf) {
                }
        }
 
-       valid = validate_recipients(recp);
+       valid = validate_recipients(recp, 
+                                   smtp_get_Recipients (),
+                                   (CC->logged_in)? POST_LOGGED_IN:POST_EXTERNAL);
        if (valid->num_error != 0) {
                cprintf("599 5.1.1 Error: %s\r\n", valid->errormsg);
                free_recipients(valid);
@@ -721,7 +729,9 @@ void smtp_data(void) {
        msg->cm_fields['V'] = strdup(SMTP->recipients);
 
        /* Submit the message into the Citadel system. */
-       valid = validate_recipients(SMTP->recipients);
+       valid = validate_recipients(SMTP->recipients, 
+                                   smtp_get_Recipients (),
+                                   (CC->logged_in)? POST_LOGGED_IN:POST_EXTERNAL);
 
        /* If there are modules that want to scan this message before final
         * submission (such as virus checkers or spam filters), call them now
@@ -1437,7 +1447,7 @@ void smtp_do_bounce(char *instr) {
                }
 
                /* Can we deliver the bounce to the original sender? */
-               valid = validate_recipients(bounceto);
+               valid = validate_recipients(bounceto, smtp_get_Recipients (), 0);
                if (valid != NULL) {
                        if (valid->num_error == 0) {
                                CtdlSubmitMsg(bmsg, valid, "");
@@ -1814,48 +1824,51 @@ const char *CitadelServiceSMTP_LMTP_UNF="LMTP-UnF";
 
 CTDL_MODULE_INIT(smtp)
 {
-       CtdlRegisterServiceHook(config.c_smtp_port,     /* SMTP MTA */
-                               NULL,
-                               smtp_mta_greeting,
-                               smtp_command_loop,
-                               NULL, 
-                               CitadelServiceSMTP_MTA);
+       if (!threading)
+       {
+               CtdlRegisterServiceHook(config.c_smtp_port,     /* SMTP MTA */
+                                       NULL,
+                                       smtp_mta_greeting,
+                                       smtp_command_loop,
+                                       NULL, 
+                                       CitadelServiceSMTP_MTA);
 
 #ifdef HAVE_OPENSSL
-       CtdlRegisterServiceHook(config.c_smtps_port,
-                               NULL,
-                               smtps_greeting,
-                               smtp_command_loop,
-                               NULL,
-                               CitadelServiceSMTPS_MTA);
+               CtdlRegisterServiceHook(config.c_smtps_port,
+                                       NULL,
+                                       smtps_greeting,
+                                       smtp_command_loop,
+                                       NULL,
+                                       CitadelServiceSMTPS_MTA);
 #endif
 
-       CtdlRegisterServiceHook(config.c_msa_port,      /* SMTP MSA */
-                               NULL,
-                               smtp_msa_greeting,
-                               smtp_command_loop,
-                               NULL,
-                               CitadelServiceSMTP_MSA);
-
-       CtdlRegisterServiceHook(0,                      /* local LMTP */
-                               file_lmtp_socket,
-                               lmtp_greeting,
-                               smtp_command_loop,
-                               NULL,
-                               CitadelServiceSMTP_LMTP);
-
-       CtdlRegisterServiceHook(0,                      /* local LMTP */
-                               file_lmtp_unfiltered_socket,
-                               lmtp_unfiltered_greeting,
-                               smtp_command_loop,
-                               NULL,
-                               CitadelServiceSMTP_LMTP_UNF);
-
-       smtp_init_spoolout();
-       CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER);
-       CtdlRegisterSessionHook(smtp_cleanup_function, EVT_STOP);
-       CtdlRegisterProtoHook(cmd_smtp, "SMTP", "SMTP utility commands");
-
+               CtdlRegisterServiceHook(config.c_msa_port,      /* SMTP MSA */
+                                       NULL,
+                                       smtp_msa_greeting,
+                                       smtp_command_loop,
+                                       NULL,
+                                       CitadelServiceSMTP_MSA);
+
+               CtdlRegisterServiceHook(0,                      /* local LMTP */
+                                       file_lmtp_socket,
+                                       lmtp_greeting,
+                                       smtp_command_loop,
+                                       NULL,
+                                       CitadelServiceSMTP_LMTP);
+
+               CtdlRegisterServiceHook(0,                      /* local LMTP */
+                                       file_lmtp_unfiltered_socket,
+                                       lmtp_unfiltered_greeting,
+                                       smtp_command_loop,
+                                       NULL,
+                                       CitadelServiceSMTP_LMTP_UNF);
+
+               smtp_init_spoolout();
+               CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER);
+               CtdlRegisterSessionHook(smtp_cleanup_function, EVT_STOP);
+               CtdlRegisterProtoHook(cmd_smtp, "SMTP", "SMTP utility commands");
+       }
+       
        /* return our Subversion id for the Log */
        return "$Id$";
 }