@@ -86,6 +86,48 @@ def getDecodedHeaders(msg, lcset):
8686
8787
8888def process (mlist , msg , msgdata ):
89+ # Check for Google Groups messages first
90+ google_groups_headers = [
91+ 'X-Google-Groups-Id' ,
92+ 'X-Google-Groups-Info' ,
93+ 'X-Google-Groups-Url' ,
94+ 'X-Google-Groups-Name' ,
95+ 'X-Google-Groups-Email'
96+ ]
97+
98+ for header in google_groups_headers :
99+ if msg .get (header ):
100+ syslog ('vette' , 'Google Groups message detected via header %s, discarding' , header )
101+ # Send bounce to the message's errors-to address
102+ try :
103+ bounce_msg = Message ()
104+ bounce_msg ['From' ] = mlist .GetBounceEmail ()
105+ # Use the message's errors-to header if present, otherwise use the From address
106+ bounce_to = msg .get ('errors-to' ) or msg .get ('from' , 'unknown' )
107+ bounce_msg ['To' ] = bounce_to
108+ bounce_msg ['Subject' ] = 'Message rejected: Google Groups not allowed'
109+ bounce_msg ['Message-ID' ] = Utils .unique_message_id (mlist )
110+ bounce_msg ['Date' ] = Utils .formatdate (localtime = True )
111+ bounce_msg ['X-Mailman-From' ] = msg .get ('from' , 'unknown' )
112+ bounce_msg ['X-Mailman-To' ] = msg .get ('to' , 'unknown' )
113+ bounce_msg ['X-Mailman-List' ] = mlist .internal_name ()
114+ bounce_msg ['X-Mailman-Reason' ] = 'Google Groups messages are not allowed'
115+
116+ # Include original message headers
117+ bounce_text = 'Original message headers:\n '
118+ for name , value in msg .items ():
119+ bounce_text += f'{ name } : { value } \n '
120+ bounce_msg .set_payload (bounce_text )
121+
122+ # Send the bounce
123+ mlist .BounceMessage (bounce_msg , msgdata )
124+ syslog ('vette' , 'Sent bounce to %s for rejected Google Groups message' , bounce_to )
125+ except Exception as e :
126+ syslog ('error' , 'Failed to send bounce for Google Groups message: %s' , str (e ))
127+
128+ # Discard the original message
129+ raise Errors .DiscardMessage
130+
89131 # Before anything else, check DMARC if necessary. We do this as early
90132 # as possible so reject/discard actions trump other holds/approvals and
91133 # wrap/munge actions get flagged even for approved messages.
0 commit comments