Skip to content

Commit 8d2a1ae

Browse files
committed
update
1 parent ec6c62d commit 8d2a1ae

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

Mailman/Handlers/SMTPDirect.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,18 @@ def bulkdeliver(mlist, msg, msgdata, envsender, failures, conn):
414414
del msg['sender']
415415
msg['Sender'] = '"%s" <%s>' % (mlist.real_name, envsender)
416416

417+
# Check for spam indicators
418+
if msg.get('X-Google-Group-Id'):
419+
mailman_log('smtp-failure', 'Message rejected: Contains X-Google-Group-Id header, likely spam')
420+
# Add all recipients to refused list
421+
for r in recips:
422+
refused[r] = (550, 'Message rejected: Contains X-Google-Group-Id header, likely spam')
423+
# Move message to bad queue
424+
badq = get_switchboard(Mailman.mm_cfg.BADQUEUE_DIR)
425+
badq.enqueue(msg, msgdata)
426+
failures.update(refused)
427+
return
428+
417429
# Get the plain, flattened text of the message
418430
msgtext = msg.as_string(mangle_from_=False)
419431
# Ensure the message text is properly encoded as UTF-8

Mailman/Queue/Switchboard.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ def dequeue(self, filebase):
159159
# Calculate the filename from the given filebase.
160160
filename = os.path.join(self.__whichq, filebase + '.pck')
161161

162+
# Check if file exists before proceeding
163+
if not os.path.exists(filename):
164+
mailman_log('warning', 'Queue file does not exist: %s', filename)
165+
return None, None
166+
162167
# Create a lock file
163168
lockfile = filename + '.lock'
164169
try:

0 commit comments

Comments
 (0)