Skip to content

Commit 78fc9e2

Browse files
author
Richard Jones
committed
Added ROUNDUPDBSENDMAILDEBUG so one can test the sendmail method...
...without actually sending mail :)
1 parent 3ff321a commit 78fc9e2

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

roundup/roundupdb.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: roundupdb.py,v 1.31 2001-12-15 19:24:39 rochecompaan Exp $
18+
# $Id: roundupdb.py,v 1.32 2001-12-15 23:48:35 richard Exp $
1919

2020
__doc__ = """
2121
Extending hyperdb with types specific to issue-tracking.
@@ -27,6 +27,9 @@
2727

2828
import hyperdb, date
2929

30+
# set to indicate to roundup not to actually _send_ email
31+
ROUNDUPDBSENDMAILDEBUG = os.environ.get('ROUNDUPDBSENDMAILDEBUG', '')
32+
3033
class DesignatorError(ValueError):
3134
pass
3235
def splitDesignator(designator, dre=re.compile(r'([^\d]+)(\d+)')):
@@ -401,10 +404,14 @@ def sendmessage(self, nodeid, msgid, change_note):
401404

402405
# now try to send the message
403406
try:
404-
smtp = smtplib.SMTP(self.MAILHOST)
405-
# send the message as admin so bounces are sent there instead
406-
# of to roundup
407-
smtp.sendmail(self.ADMIN_EMAIL, sendto, message.getvalue())
407+
if ROUNDUPDBSENDMAILDEBUG:
408+
print 'From: %s\nTo: %s\n%s\n=-=-=-=-=-=-=-='%(
409+
self.ADMIN_EMAIL, sendto, message.getvalue())
410+
else:
411+
smtp = smtplib.SMTP(self.MAILHOST)
412+
# send the message as admin so bounces are sent there instead
413+
# of to roundup
414+
smtp.sendmail(self.ADMIN_EMAIL, sendto, message.getvalue())
408415
except socket.error, value:
409416
raise MessageSendError, \
410417
"Couldn't send confirmation email: mailhost %s"%value
@@ -497,6 +504,13 @@ def generateChangeNote(self, nodeid, oldvalues):
497504

498505
#
499506
# $Log: not supported by cvs2svn $
507+
# Revision 1.31 2001/12/15 19:24:39 rochecompaan
508+
# . Modified cgi interface to change properties only once all changes are
509+
# collected, files created and messages generated.
510+
# . Moved generation of change note to nosyreactors.
511+
# . We now check for changes to "assignedto" to ensure it's added to the
512+
# nosy list.
513+
#
500514
# Revision 1.30 2001/12/12 21:47:45 richard
501515
# . Message author's name appears in From: instead of roundup instance name
502516
# (which still appears in the Reply-To:)

0 commit comments

Comments
 (0)