From c903c9232fd0bf9bb84ecacc2aa678a0fa3ada43 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Tue, 27 Aug 2024 08:17:52 +0100
Subject: [PATCH] Reject null senders delivering directly to mailing list

Bounces should use the -bounce address.
---
 Mailman/Queue/LMTPRunner.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Mailman/Queue/LMTPRunner.py b/Mailman/Queue/LMTPRunner.py
index 57bfdd9..8a90fa2 100644
--- a/Mailman/Queue/LMTPRunner.py
+++ b/Mailman/Queue/LMTPRunner.py
@@ -468,6 +468,10 @@ class LMTPRunner(Runner, smtpd.SMTPServer):
                         ))
                     queue = Switchboard(mm_cfg.INQUEUE_DIR)
                 elif subaddress is None:
+                    # Reject null senders when delivering to the main list queue.
+                    if mailfrom == '<>':
+                        status.append('550 '+EERR_572)
+                        continue
                     msgdata['tolist'] = True
                     queue = Switchboard(mm_cfg.INQUEUE_DIR)
                 elif subaddress == 'request':
-- 
GitLab