From cbb34ec7ddd735aec6e55625259b19f869613329 Mon Sep 17 00:00:00 2001
From: Art Cancro
-
There are actually two LMTP sockets. One is called +lmtp.socket and the other is called lmtp-unfiltered.socket +(both are found in your Citadel directory). The difference should be +obvious: messages submitted via lmtp.socket are subject to any +spam filtering you may have configured (such as SpamAssassin), while messages +submitted via lmtp-unfiltered.socket will bypass the filters. You +would use the filtered socket when receiving mail from an external MTA such +as Postfix, but you might want to use the unfiltered socket with utilities +such as fetchmail.
+For outbound mail, you can either allow Citadel to perform deliveries directly diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index 88fd3e684..a1ff19cdd 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -92,6 +92,7 @@ struct citsmtp { /* Information about the current session */ int delivery_mode; int message_originated_locally; int is_lmtp; + int is_unfiltered; int is_msa; }; @@ -168,6 +169,16 @@ void lmtp_greeting(void) { } +/* + * We also have an unfiltered LMTP socket that bypasses spam filters. + */ +void lmtp_unfiltered_greeting(void) { + smtp_greeting(); + SMTP->is_lmtp = 1; + SMTP->is_unfiltered = 1; +} + + /* * Login greeting common to all auth methods */ @@ -454,6 +465,7 @@ void smtp_expn(char *argbuf) { */ void smtp_rset(int do_response) { int is_lmtp; + int is_unfiltered; /* * Our entire SMTP state is discarded when a RSET command is issued, @@ -461,6 +473,7 @@ void smtp_rset(int do_response) { * we save it for later. */ is_lmtp = SMTP->is_lmtp; + is_unfiltered = SMTP->is_unfiltered; memset(SMTP, 0, sizeof(struct citsmtp)); @@ -479,6 +492,7 @@ void smtp_rset(int do_response) { * Reinstate this little piece of information we saved (see above). */ SMTP->is_lmtp = is_lmtp; + SMTP->is_unfiltered = is_unfiltered; if (do_response) { cprintf("250 2.0.0 Zap!\r\n"); @@ -724,7 +738,12 @@ void smtp_data(void) { * submission (such as virus checkers or spam filters), call them now * and give them an opportunity to reject the message. */ - scan_errors = PerformMessageHooks(msg, EVT_SMTPSCAN); + if (SMTP->is_unfiltered) { + scan_errors = 0; + } + else { + scan_errors = PerformMessageHooks(msg, EVT_SMTPSCAN); + } if (scan_errors > 0) { /* We don't want this message! */ @@ -1692,6 +1711,12 @@ char *serv_smtp_init(void) smtp_command_loop, NULL); + CtdlRegisterServiceHook(0, /* local LMTP */ + "lmtp-unfiltered.socket", + lmtp_unfiltered_greeting, + smtp_command_loop, + NULL); + smtp_init_spoolout(); CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER); CtdlRegisterSessionHook(smtp_cleanup_function, EVT_STOP); -- 2.39.2