Mercurial > p > roundup > code
changeset 1524:1bb5e4dd12f3
fixed rego email bugs [SF#699809]
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 18 Mar 2003 00:24:35 +0000 |
| parents | 63aa7be52d2c |
| children | c006e8166f81 |
| files | roundup/cgi/client.py |
| diffstat | 1 files changed, 27 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/cgi/client.py Mon Mar 17 22:03:08 2003 +0000 +++ b/roundup/cgi/client.py Tue Mar 18 00:24:35 2003 +0000 @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.106 2003-03-17 04:46:20 richard Exp $ +# $Id: client.py,v 1.107 2003-03-18 00:24:35 richard Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -27,6 +27,11 @@ class NotModified(HTTPException): pass +# set to indicate to roundup not to actually _send_ email +# this var must contain a file to write the mail to +SENDMAILDEBUG = os.environ.get('SENDMAILDEBUG', '') + + # XXX actually _use_ FormError class FormError(ValueError): ''' An "expected" exception occurred during form parsing. @@ -280,9 +285,9 @@ # remove aged otks otks = self.db.otks for sessid in otks.list(): - interval = now - okts.get(sessid, '__time') + interval = now - otks.get(sessid, '__time') if interval > week: - otk.destroy(sessid) + otks.destroy(sessid) sessions.set('last_clean', last_use=time.time()) def determine_user(self): @@ -763,18 +768,25 @@ content = StringIO.StringIO(content) quopri.encode(content, body, 0) - # now try to send the message - try: - # send the message as admin so bounces are sent there - # instead of to roundup - smtp = smtplib.SMTP(self.db.config.MAILHOST) - smtp.sendmail(self.db.config.ADMIN_EMAIL, [to], message.getvalue()) - except socket.error, value: - self.error_message.append("Error: couldn't send email: " - "mailhost %s"%value) - return 0 - except smtplib.SMTPException, value: - self.error_message.append("Error: couldn't send email: %s"%value) + if SENDMAILDEBUG: + # don't send - just write to a file + open(SENDMAILDEBUG, 'a').write('FROM: %s\nTO: %s\n%s\n'%( + self.db.config.ADMIN_EMAIL, + ', '.join(to),message.getvalue())) + else: + # now try to send the message + try: + # send the message as admin so bounces are sent there + # instead of to roundup + smtp = smtplib.SMTP(self.db.config.MAILHOST) + smtp.sendmail(self.db.config.ADMIN_EMAIL, [to], + message.getvalue()) + except socket.error, value: + self.error_message.append("Error: couldn't send email: " + "mailhost %s"%value) + return 0 + except smtplib.SMTPException, msg: + self.error_message.append("Error: couldn't send email: %s"%msg) return 0 return 1
