@@ -73,7 +73,7 @@ class node. Any parts of other types are each stored in separate files
7373an exception, the original message is bounced back to the sender with the
7474explanatory message given in the exception.
7575
76- $Id: mailgw.py,v 1.100 2002-12-10 00:11:15 richard Exp $
76+ $Id: mailgw.py,v 1.101 2002-12-10 00:23:35 richard Exp $
7777'''
7878
7979import string , re , os , mimetools , cStringIO , smtplib , socket , binascii , quopri
@@ -92,6 +92,10 @@ class MailUsageError(ValueError):
9292class MailUsageHelp (Exception ):
9393 pass
9494
95+ class MailLoop (Exception ):
96+ ''' We've seen this message before... '''
97+ pass
98+
9599class Unauthorized (Exception ):
96100 """ Access denied """
97101
@@ -270,8 +274,12 @@ def handle_Message(self, message):
270274 m = ['' ]
271275 m .append (str (value ))
272276 m = self .bounce_message (message , sendto , m )
277+ except MailLoop :
278+ # XXX we should use a log file here...
279+ return
273280 except :
274281 # bounce the message back to the sender with the error message
282+ # XXX we should use a log file here...
275283 sendto = [sendto [0 ][1 ], self .instance .config .ADMIN_EMAIL ]
276284 m = ['' ]
277285 m .append ('An unexpected error occurred during the processing' )
@@ -285,6 +293,7 @@ def handle_Message(self, message):
285293 m = self .bounce_message (message , sendto , m )
286294 else :
287295 # very bad-looking message - we don't even know who sent it
296+ # XXX we should use a log file here...
288297 sendto = [self .instance .config .ADMIN_EMAIL ]
289298 m = ['Subject: badly formed message from mail gateway' ]
290299 m .append ('' )
@@ -319,6 +328,7 @@ def bounce_message(self, message, sendto, error,
319328 '''
320329 msg = cStringIO .StringIO ()
321330 writer = MimeWriter .MimeWriter (msg )
331+ writer .addheader ('X-Roundup-Loop' , 'hello' )
322332 writer .addheader ('Subject' , subject )
323333 writer .addheader ('From' , '%s <%s>' % (self .instance .config .TRACKER_NAME ,
324334 self .instance .config .TRACKER_EMAIL ))
@@ -371,6 +381,10 @@ def handle_message(self, message):
371381
372382 Parse the message as per the module docstring.
373383 '''
384+ # detect loops
385+ if message .getheader ('x-roundup-loop' , '' ):
386+ raise MailLoop
387+
374388 # handle the subject line
375389 subject = message .getheader ('subject' , '' )
376390
0 commit comments