summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dde843e)
raw | patch | inline | side by side (parent: dde843e)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 25 Mar 2004 22:52:12 +0000 (22:52 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 25 Mar 2004 22:52:12 +0000 (22:52 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2191 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/mailer.py | patch | blob | history | |
roundup/mailgw.py | patch | blob | history |
diff --git a/roundup/mailer.py b/roundup/mailer.py
index 93ef7f9ba5d26b3517014c86c42ec292f3a6bf3e..e3f4f7590c47900041a7a8b856e1f908765e0882 100644 (file)
--- a/roundup/mailer.py
+++ b/roundup/mailer.py
"""Sending Roundup-specific mail over SMTP.
"""
__docformat__ = 'restructuredtext'
-# $Id: mailer.py,v 1.7 2004-02-29 00:35:55 richard Exp $
+# $Id: mailer.py,v 1.8 2004-03-25 22:52:12 richard Exp $
import time, quopri, os, socket, smtplib, re
Arguments:
- bounced_message: an RFC822 Message object.
- - to: a list of addresses usable by rfc822.parseaddr().
+ - to: a list of addresses usable by rfc822.parseaddr(). Might be
+ extended or overridden according to the config
+ ERROR_MESSAGES_TO setting.
- error: the reason of failure as a string.
- subject: the subject as a string.
-
+
"""
message, writer = self.get_standard_message(to, subject)
+ # see whether we should send to the dispatcher or not
+ dispatcher_email = getattr(self.config, "DISPATCHER_EMAIL",
+ getattr(self.config, "ADMIN_EMAIL"))
+ error_messages_to = getattr(self.config, "ERROR_MESSAGES_TO", "user")
+ if error_messages_to == "dispatcher":
+ to = [dispatcher_email]
+ elif error_messages_to == "both":
+ to.append(dispatcher_email)
+
part = writer.startmultipartbody('mixed')
part = writer.nextpart()
part.addheader('Content-Transfer-Encoding', 'quoted-printable')
diff --git a/roundup/mailgw.py b/roundup/mailgw.py
index 6b1fb936a89e7d4d6a2b8fdc3069713791f838c3..d6768758397eb4c364676831387b613c5f43284e 100644 (file)
--- a/roundup/mailgw.py
+++ b/roundup/mailgw.py
an exception, the original message is bounced back to the sender with the
explanatory message given in the exception.
-$Id: mailgw.py,v 1.144 2004-03-25 19:27:15 eparker Exp $
+$Id: mailgw.py,v 1.145 2004-03-25 22:52:12 richard Exp $
"""
__docformat__ = 'restructuredtext'
# in some rare cases, a particularly stuffed-up e-mail will make
# its way into here... try to handle it gracefully
- # Setting the dispatcher e-mail here, so as not to clutter things. Defaulting to ADMIN_EMAIL, if not set.
- dispatcherEmail = getattr(self.instance.config, "DISPATCHER_EMAIL", getattr(self.instance.config, "ADMIN_EMAIL"))
- errorMessagesTo = getattr(self.instance.config, "ERROR_MESSAGES_TO", "user")
-
sendto = message.getaddrlist('resent-from')
if not sendto:
sendto = message.getaddrlist('from')
# very bad-looking message - we don't even know who sent it
# XXX we should use a log file here...
- # [EP] This section was originally only to admin.. Not sure if this should ever go to the user?
-
- if(errorMessagesTo == "dispatcher"):
- sendto = [dispatcherEmail]
- elif(errorMessagesTo == "both"):
- sendto = [dispatcherEmail, self.instance.config.ADMIN_EMAIL]
- else:
- sendto = [self.instance.config.ADMIN_EMAIL]
+ sendto = [self.instance.config.ADMIN_EMAIL]
m = ['Subject: badly formed message from mail gateway']
m.append('')
except MailUsageHelp:
# bounce the message back to the sender with the usage message
fulldoc = '\n'.join(string.split(__doc__, '\n')[2:])
- if(errorMessagesTo == "dispatcher"):
- sendto = [dispatcherEmail]
- elif(errorMessagesTo == "both"):
- sendto = [dispatcherEmail, sendto[0][1]]
- else:
- sendto = [sendto[0][1]]
-
m = ['']
m.append('\n\nMail Gateway Help\n=================')
m.append(fulldoc)
- self.mailer.bounce_message(message, sendto, m,
+ self.mailer.bounce_message(message, [sendto[0][1]], m,
subject="Mail Gateway Help")
except MailUsageError, value:
# bounce the message back to the sender with the usage message
fulldoc = '\n'.join(string.split(__doc__, '\n')[2:])
-
- if(errorMessagesTo == "dispatcher"):
- sendto = [dispatcherEmail]
- elif(errorMessagesTo == "both"):
- sendto = [dispatcherEmail, sendto[0][1]]
- else:
- sendto = [sendto[0][1]]
m = ['']
m.append(str(value))
m.append('\n\nMail Gateway Help\n=================')
m.append(fulldoc)
- self.mailer.bounce_message(message, sendto, m)
+ self.mailer.bounce_message(message, [sendto[0][1]], m)
except Unauthorized, value:
# just inform the user that he is not authorized
-
- if(errorMessagesTo == "dispatcher"):
- sendto = [dispatcherEmail]
- elif(errorMessagesTo == "both"):
- sendto = [dispatcherEmail, sendto[0][1]]
- else:
- sendto = [sendto[0][1]]
m = ['']
m.append(str(value))
- self.mailer.bounce_message(message, sendto, m)
+ self.mailer.bounce_message(message, [sendto[0][1]], m)
except IgnoreMessage:
# XXX we should use a log file here...
# do not take any action
except:
# bounce the message back to the sender with the error message
# XXX we should use a log file here...
-
- if(errorMessagesTo == "dispatcher"):
- sendto = [dispatcherEmail]
- elif(errorMessagesTo == "both"):
- sendto = [dispatcherEmail, sendto[0][1], self.instance.config.ADMIN_EMAIL]
- else:
- sendto = [sendto[0][1], self.instance.config.ADMIN_EMAIL]
-
+ # let the admin know that something very bad is happening
+ sendto = [sendto[0][1], self.instance.config.ADMIN_EMAIL]
m = ['']
m.append('An unexpected error occurred during the processing')
m.append('of your message. The tracker administrator is being')