Mail to a mailing list room must be from a subscriber (or a logged in user) otherwise...
[citadel.git] / citadel / modules / smtp / serv_smtp.c
index a74e2bb9fa7fc0fdf9927a937afd42d484ac520d..549a291658758fd6e23347171319ac3b29f14df8 100644 (file)
@@ -715,6 +715,16 @@ void smtp_rcpt(void) {
                return;
        }
 
+       if (
+               (valid->num_room > 0)                                           // If it's mail to a room (mailing list)...
+               && (SMTP->message_originated_locally == 0)                      // ...and also inbound Internet mail...
+               && (is_email_subscribed_to_list((char *)ChrPtr(SMTP->from), valid->recp_room) == 0)     // ...and not a subscriber
+       ) {
+               cprintf("551 <%s> - This mailing list only accepts messages from subscribers.\r\n", ChrPtr(SMTP->OneRcpt));
+               free_recipients(valid);
+               return;
+       }
+
        cprintf("250 RCPT ok <%s>\r\n", ChrPtr(SMTP->OneRcpt));
        if (StrLength(SMTP->recipients) > 0) {
                StrBufAppendBufPlain(SMTP->recipients, HKEY(","), 0);