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

Benjamin Renard commited on 2012-04-20 15:57:54
Showing 1 changed files, with 11 additions and 2 deletions.

... ...
@@ -178,10 +178,19 @@ class MantisSMTPServer(smtpd.SMTPServer):
178 178
 				logging.info('Add attachment to issue %s : %s' % (issue_id,attachment['filename']))
179 179
 				self.ws.add_attachment_to_issue(issue_id,attachment)
180 180
 			except MantisWS.MantisWSError, e:
181
-				logging.error('MantisWS error adding attachment %s to issue %s : %s.' % (attachment['filename'],issue_id, e))
182
-
181
+				logging.error('MantisWS error adding attachment %s to issue %s : %s. Warning sender by mail.' % (attachment['filename'],issue_id, e))
182
+				self.alert_sender(
183
+					msg,
184
+					u"[Mantis] WS error adding attachment %s to issue %s" % (attachment['filename'],issue_id),
185
+					u"MantisWS error occurded attaching your file '%s' in your mail '%s' to issue %s." % (attachment['filename'],msg.subject(),issue_id)
186
+				)
183 187
 			except Exception, e:
184 188
 				logging.error('Unknown error adding attachment %s to issue %s : %s. Warning sender by mail.' % (attachment['filename'],issue_id,e))
189
+				self.alert_sender(
190
+					msg,
191
+					u"[Mantis] Unknown error adding attachment %s to issue %s" % (attachment['filename'],issue_id),
192
+					u"Unknown error occurded attaching your file '%s' in your mail '%s' to issue %s." % (attachment['filename'],msg.subject(),issue_id)
193
+				)
185 194
 
186 195
 
187 196
 	def save_msg(self,peer, mailfrom, rcpttos, data):
188 197