comparison roundup/mailer.py @ 2123:95da13c1bdbd

have bounce_message do the error_messages_to heavy-lifting
author Richard Jones <richard@users.sourceforge.net>
date Thu, 25 Mar 2004 22:52:12 +0000
parents 48600089c73d
children 6deda7ff3b2a
comparison
equal deleted inserted replaced
2122:7109f83d5250 2123:95da13c1bdbd
1 """Sending Roundup-specific mail over SMTP. 1 """Sending Roundup-specific mail over SMTP.
2 """ 2 """
3 __docformat__ = 'restructuredtext' 3 __docformat__ = 'restructuredtext'
4 # $Id: mailer.py,v 1.7 2004-02-29 00:35:55 richard Exp $ 4 # $Id: mailer.py,v 1.8 2004-03-25 22:52:12 richard Exp $
5 5
6 import time, quopri, os, socket, smtplib, re 6 import time, quopri, os, socket, smtplib, re
7 7
8 from cStringIO import StringIO 8 from cStringIO import StringIO
9 from MimeWriter import MimeWriter 9 from MimeWriter import MimeWriter
90 subject='Failed issue tracker submission'): 90 subject='Failed issue tracker submission'):
91 """Bounce a message, attaching the failed submission. 91 """Bounce a message, attaching the failed submission.
92 92
93 Arguments: 93 Arguments:
94 - bounced_message: an RFC822 Message object. 94 - bounced_message: an RFC822 Message object.
95 - to: a list of addresses usable by rfc822.parseaddr(). 95 - to: a list of addresses usable by rfc822.parseaddr(). Might be
96 extended or overridden according to the config
97 ERROR_MESSAGES_TO setting.
96 - error: the reason of failure as a string. 98 - error: the reason of failure as a string.
97 - subject: the subject as a string. 99 - subject: the subject as a string.
98 100
99 """ 101 """
100 message, writer = self.get_standard_message(to, subject) 102 message, writer = self.get_standard_message(to, subject)
103
104 # see whether we should send to the dispatcher or not
105 dispatcher_email = getattr(self.config, "DISPATCHER_EMAIL",
106 getattr(self.config, "ADMIN_EMAIL"))
107 error_messages_to = getattr(self.config, "ERROR_MESSAGES_TO", "user")
108 if error_messages_to == "dispatcher":
109 to = [dispatcher_email]
110 elif error_messages_to == "both":
111 to.append(dispatcher_email)
101 112
102 part = writer.startmultipartbody('mixed') 113 part = writer.startmultipartbody('mixed')
103 part = writer.nextpart() 114 part = writer.nextpart()
104 part.addheader('Content-Transfer-Encoding', 'quoted-printable') 115 part.addheader('Content-Transfer-Encoding', 'quoted-printable')
105 body = part.startbody('text/plain; charset=utf-8') 116 body = part.startbody('text/plain; charset=utf-8')

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