+

MantisSMTPServer : send email alert to sender on error adding his attached file

Benjamin Renard [2012-04-20 15:57:54]
MantisSMTPServer : send email alert to sender on error adding his attached file
Filename
src/usr/share/mantis-smtp/MantisSMTPServer.py
diff --git a/src/usr/share/mantis-smtp/MantisSMTPServer.py b/src/usr/share/mantis-smtp/MantisSMTPServer.py
index 0b41a7d..3f195e9 100755
--- a/src/usr/share/mantis-smtp/MantisSMTPServer.py
+++ b/src/usr/share/mantis-smtp/MantisSMTPServer.py
@@ -178,10 +178,19 @@ class MantisSMTPServer(smtpd.SMTPServer):
 				logging.info('Add attachment to issue %s : %s' % (issue_id,attachment['filename']))
 				self.ws.add_attachment_to_issue(issue_id,attachment)
 			except MantisWS.MantisWSError, e:
-				logging.error('MantisWS error adding attachment %s to issue %s : %s.' % (attachment['filename'],issue_id, e))
-
+				logging.error('MantisWS error adding attachment %s to issue %s : %s. Warning sender by mail.' % (attachment['filename'],issue_id, e))
+				self.alert_sender(
+					msg,
+					u"[Mantis] WS error adding attachment %s to issue %s" % (attachment['filename'],issue_id),
+					u"MantisWS error occurded attaching your file '%s' in your mail '%s' to issue %s." % (attachment['filename'],msg.subject(),issue_id)
+				)
 			except Exception, e:
 				logging.error('Unknown error adding attachment %s to issue %s : %s. Warning sender by mail.' % (attachment['filename'],issue_id,e))
+				self.alert_sender(
+					msg,
+					u"[Mantis] Unknown error adding attachment %s to issue %s" % (attachment['filename'],issue_id),
+					u"Unknown error occurded attaching your file '%s' in your mail '%s' to issue %s." % (attachment['filename'],msg.subject(),issue_id)
+				)


 	def save_msg(self,peer, mailfrom, rcpttos, data):
ViewGit