Ticket #77: email2trac.diff
File email2trac.diff, 1.9 KB (added by jon.wbstr@…, 16 years ago) |
---|
-
email2trac.py
305 305 306 306 return False 307 307 308 def allowed_recipient(self): 309 """ 310 This function wil check if the email address is configured to receive tickets. 311 """ 312 try: 313 toaddress_list = self.parameters['rcptaddress_list'] 314 except KeyError, detail: 315 if self.DEBUG > 2 : 316 print 'rcptaddress_list not defined, all messages allowed.' 317 return True 318 319 toaddress_list = string.split(toaddress_list) 320 for entry in toaddress_list: 321 entry = entry.strip() 322 TO_RE = re.compile(entry, re.VERBOSE|re.IGNORECASE) 323 result = TO_RE.search(self.to_email_addr) 324 if result: 325 return True 326 327 return False 328 308 329 def email_to_unicode(self, message_str): 309 330 """ 310 331 Email has 7 bit ASCII code, convert it to unicode with the charset … … 405 426 406 427 self.email_from = self.email_to_unicode(message['from']) 407 428 self.author, self.email_addr = email.Utils.parseaddr(self.email_from) 429 """ 430 Get the recipients name and email address 431 """ 432 self.email_to = self.email_to_unicode(message['to']) 433 self.to_name, self.to_email_addr = email.Utils.parseaddr (self.email_to) 408 434 409 435 # Maybe for later user 410 436 #self.email_from = self.email_to_unicode(self.email_addr) … … 794 820 print 'Message rejected : From: in blacklist' 795 821 return False 796 822 823 if not self.allowed_recipient(): 824 if self.DEBUG > 1 : 825 print 'Message rejected : To: not permitted' 826 return False 827 797 828 # If drop the message 798 829 # 799 830 if self.spam(m) == 'drop': … … 1062 1093 1063 1094 os.unlink(path) 1064 1095 continue 1096 elif (filename == 'winmail.dat') or (filename == 'part0001.html'): 1097 #status = '%s\nFile %s not wanted.\n\n' \ 1098 # %(status, filename) 1099 1100 os.unlink(path) 1101 continue 1065 1102 else: 1066 1103 count = count + 1 1067 1104