comparison roundup/mailgw.py @ 3374:3f12b4bcf796 maint-0.8

merge from HEAD
author Richard Jones <richard@users.sourceforge.net>
date Fri, 24 Jun 2005 07:19:04 +0000
parents 246fed02a51e
children aaf00739eb96
comparison
equal deleted inserted replaced
3372:086c634156e6 3374:3f12b4bcf796
70 set() method to add the message to the item's spool; in the second case we 70 set() method to add the message to the item's spool; in the second case we
71 are calling the create() method to create a new node). If an auditor raises 71 are calling the create() method to create a new node). If an auditor raises
72 an exception, the original message is bounced back to the sender with the 72 an exception, the original message is bounced back to the sender with the
73 explanatory message given in the exception. 73 explanatory message given in the exception.
74 74
75 $Id: mailgw.py,v 1.159.2.5 2005-06-24 06:48:17 richard Exp $ 75 $Id: mailgw.py,v 1.159.2.6 2005-06-24 07:17:08 richard Exp $
76 """ 76 """
77 __docformat__ = 'restructuredtext' 77 __docformat__ = 'restructuredtext'
78 78
79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri 79 import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
80 import time, random, sys, logging 80 import time, random, sys, logging
81 import traceback, MimeWriter, rfc822 81 import traceback, MimeWriter, rfc822
82 82
83 from roundup import hyperdb, date, password, rfc2822, exceptions 83 from roundup import hyperdb, date, password, rfc2822, exceptions
84 from roundup.mailer import Mailer 84 from roundup.mailer import Mailer, MessageSendError
85 85
86 SENDMAILDEBUG = os.environ.get('SENDMAILDEBUG', '') 86 SENDMAILDEBUG = os.environ.get('SENDMAILDEBUG', '')
87 87
88 class MailGWError(ValueError): 88 class MailGWError(ValueError):
89 pass 89 pass
544 self.mailer.bounce_message(message, [sendto[0][1]], m) 544 self.mailer.bounce_message(message, [sendto[0][1]], m)
545 except Unauthorized, value: 545 except Unauthorized, value:
546 # just inform the user that he is not authorized 546 # just inform the user that he is not authorized
547 m = [''] 547 m = ['']
548 m.append(str(value)) 548 m.append(str(value))
549 self.mailer.bounce_message(message, [sendto[0][1]], m) 549 try:
550 self.mailer.bounce_message(message, [sendto[0][1]], m)
551 except MessageSendError, error:
552 # if the only reason the bounce failed is because of
553 # invalid addresses to bounce the message back to, then
554 # just discard the message - it's just not worth bothering
555 # with (most likely spam / otherwise forged)
556 invalid = True
557 for address, (code, reason) in error.keys():
558 if code != 550:
559 invalid = False
560 if not invalid:
561 raise
550 except IgnoreMessage: 562 except IgnoreMessage:
551 # do not take any action 563 # do not take any action
552 # this exception is thrown when email should be ignored 564 # this exception is thrown when email should be ignored
553 msg = 'IgnoreMessage raised' 565 msg = 'IgnoreMessage raised'
554 if message.getheader('message-id'): 566 if message.getheader('message-id'):

Roundup Issue Tracker: http://roundup-tracker.org/