@@ -72,7 +72,7 @@ class node. Any parts of other types are each stored in separate files
7272an exception, the original message is bounced back to the sender with the
7373explanatory message given in the exception.
7474
75- $Id: mailgw.py,v 1.143 2004-02-11 23:55:08 richard Exp $
75+ $Id: mailgw.py,v 1.144 2004-03-25 19:27:15 eparker Exp $
7676"""
7777__docformat__ = 'restructuredtext'
7878
@@ -429,13 +429,27 @@ def handle_Message(self, message):
429429 """
430430 # in some rare cases, a particularly stuffed-up e-mail will make
431431 # its way into here... try to handle it gracefully
432+
433+ # Setting the dispatcher e-mail here, so as not to clutter things. Defaulting to ADMIN_EMAIL, if not set.
434+ dispatcherEmail = getattr (self .instance .config , "DISPATCHER_EMAIL" , getattr (self .instance .config , "ADMIN_EMAIL" ))
435+ errorMessagesTo = getattr (self .instance .config , "ERROR_MESSAGES_TO" , "user" )
436+
432437 sendto = message .getaddrlist ('resent-from' )
433438 if not sendto :
434439 sendto = message .getaddrlist ('from' )
435440 if not sendto :
436441 # very bad-looking message - we don't even know who sent it
437442 # XXX we should use a log file here...
438- sendto = [self .instance .config .ADMIN_EMAIL ]
443+
444+ # [EP] This section was originally only to admin.. Not sure if this should ever go to the user?
445+
446+ if (errorMessagesTo == "dispatcher" ):
447+ sendto = [dispatcherEmail ]
448+ elif (errorMessagesTo == "both" ):
449+ sendto = [dispatcherEmail , self .instance .config .ADMIN_EMAIL ]
450+ else :
451+ sendto = [self .instance .config .ADMIN_EMAIL ]
452+
439453 m = ['Subject: badly formed message from mail gateway' ]
440454 m .append ('' )
441455 m .append ('The mail gateway retrieved a message which has no From:' )
@@ -454,7 +468,13 @@ def handle_Message(self, message):
454468 except MailUsageHelp :
455469 # bounce the message back to the sender with the usage message
456470 fulldoc = '\n ' .join (string .split (__doc__ , '\n ' )[2 :])
457- sendto = [sendto [0 ][1 ]]
471+ if (errorMessagesTo == "dispatcher" ):
472+ sendto = [dispatcherEmail ]
473+ elif (errorMessagesTo == "both" ):
474+ sendto = [dispatcherEmail , sendto [0 ][1 ]]
475+ else :
476+ sendto = [sendto [0 ][1 ]]
477+
458478 m = ['' ]
459479 m .append ('\n \n Mail Gateway Help\n =================' )
460480 m .append (fulldoc )
@@ -463,15 +483,27 @@ def handle_Message(self, message):
463483 except MailUsageError , value :
464484 # bounce the message back to the sender with the usage message
465485 fulldoc = '\n ' .join (string .split (__doc__ , '\n ' )[2 :])
466- sendto = [sendto [0 ][1 ]]
486+
487+ if (errorMessagesTo == "dispatcher" ):
488+ sendto = [dispatcherEmail ]
489+ elif (errorMessagesTo == "both" ):
490+ sendto = [dispatcherEmail , sendto [0 ][1 ]]
491+ else :
492+ sendto = [sendto [0 ][1 ]]
467493 m = ['' ]
468494 m .append (str (value ))
469495 m .append ('\n \n Mail Gateway Help\n =================' )
470496 m .append (fulldoc )
471497 self .mailer .bounce_message (message , sendto , m )
472498 except Unauthorized , value :
473499 # just inform the user that he is not authorized
474- sendto = [sendto [0 ][1 ]]
500+
501+ if (errorMessagesTo == "dispatcher" ):
502+ sendto = [dispatcherEmail ]
503+ elif (errorMessagesTo == "both" ):
504+ sendto = [dispatcherEmail , sendto [0 ][1 ]]
505+ else :
506+ sendto = [sendto [0 ][1 ]]
475507 m = ['' ]
476508 m .append (str (value ))
477509 self .mailer .bounce_message (message , sendto , m )
@@ -483,7 +515,14 @@ def handle_Message(self, message):
483515 except :
484516 # bounce the message back to the sender with the error message
485517 # XXX we should use a log file here...
486- sendto = [sendto [0 ][1 ], self .instance .config .ADMIN_EMAIL ]
518+
519+ if (errorMessagesTo == "dispatcher" ):
520+ sendto = [dispatcherEmail ]
521+ elif (errorMessagesTo == "both" ):
522+ sendto = [dispatcherEmail , sendto [0 ][1 ], self .instance .config .ADMIN_EMAIL ]
523+ else :
524+ sendto = [sendto [0 ][1 ], self .instance .config .ADMIN_EMAIL ]
525+
487526 m = ['' ]
488527 m .append ('An unexpected error occurred during the processing' )
489528 m .append ('of your message. The tracker administrator is being' )
0 commit comments