Skip to content

Commit 0dcefa6

Browse files
committed
update
1 parent 8f8b0db commit 0dcefa6

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

Mailman/Handlers/SMTPDirect.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,13 @@ def process(mlist, msg, msgdata):
174174

175175
# Check for spam headers first
176176
if msg.get('x-google-group-id'):
177-
mailman_log('error', 'Rejecting message with X-Google-Group-Id header')
177+
mailman_log('error', 'Silently dropping message with X-Google-Group-Id header')
178178
# Add all recipients to refused list with 550 error
179179
for r in recips:
180180
refused[r] = (550, 'Message rejected due to spam detection')
181181
# Update failures dict
182182
msgdata['failures'] = refused
183+
# Silently return without raising an exception
183184
return
184185

185186
# Chunkify the recipients

Mailman/MailList.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,3 +1432,42 @@ def CheckPending(self, email, unsub=False):
14321432
data.lower() == email.lower()):
14331433
return True
14341434
return False
1435+
1436+
def GetBannedPattern(self, email):
1437+
"""Check if the email address matches any banned patterns.
1438+
1439+
Args:
1440+
email: The email address to check
1441+
1442+
Returns:
1443+
The matching pattern if found, None otherwise
1444+
"""
1445+
if not self.ban_list:
1446+
return None
1447+
1448+
# Convert email to lowercase for case-insensitive matching
1449+
email = email.lower()
1450+
1451+
# Check each pattern in the ban list
1452+
for pattern in self.ban_list:
1453+
# Skip empty patterns
1454+
if not pattern.strip():
1455+
continue
1456+
1457+
# If pattern starts with @, it's a domain pattern
1458+
if pattern.startswith('@'):
1459+
domain = pattern[1:].lower()
1460+
if email.endswith(domain):
1461+
return pattern
1462+
# Otherwise it's a regex pattern
1463+
else:
1464+
try:
1465+
cre = re.compile(pattern, re.IGNORECASE)
1466+
if cre.search(email):
1467+
return pattern
1468+
except re.error:
1469+
syslog('error', 'Invalid regex pattern in ban_list: %s',
1470+
pattern)
1471+
continue
1472+
1473+
return None

0 commit comments

Comments
 (0)