2121import copy
2222import textwrap
2323import traceback
24+ import datetime
2425
2526# Testing mode:
2627# import ietf.utils.mail
@@ -228,6 +229,19 @@ def condition_message(to, frm, subject, msg, cc, extra):
228229 if v :
229230 msg [k ] = v
230231
232+ def show_that_mail_was_sent (request ,leadline ,msg ,bcc ):
233+ if request and request .user :
234+ from ietf .ietfauth .utils import has_role
235+ if has_role (request .user ,['Area Director' ,'Secretariat' ,'IANA' ,'RFC Editor' ,'ISE' ,'IAD' ,'IRTF Chair' ,'WG Chair' ,'RG Chair' ,'WG Secretary' ,'RG Secretary' ]):
236+ info = "%s at %s %s\n " % (leadline ,datetime .datetime .now ().strftime ("%Y-%m-%d %H:%M:%S" ),settings .TIME_ZONE )
237+ info += "Subject: %s\n " % msg .get ('Subject' ,'[no subject]' )
238+ info += "To: %s\n " % msg .get ('To' ,'[no to]' )
239+ if msg .get ('Cc' ):
240+ info += "Cc: %s\n " % msg .get ('Cc' )
241+ if bcc :
242+ info += "Bcc: %s\n " % bcc
243+ messages .info (request ,info ,extra_tags = 'preformatted' ,fail_silently = True )
244+
231245def send_mail_mime (request , to , frm , subject , msg , cc = None , extra = None , toUser = False , bcc = None ):
232246 """Send MIME message with content already filled in."""
233247
@@ -238,13 +252,18 @@ def send_mail_mime(request, to, frm, subject, msg, cc=None, extra=None, toUser=F
238252 # and EMAIL_PORT=2025 in settings_local.py
239253 debugging = getattr (settings , "USING_DEBUG_EMAIL_SERVER" , False ) and settings .EMAIL_HOST == 'localhost' and settings .EMAIL_PORT == 2025
240254
255+ if settings .SERVER_MODE == 'development' :
256+ show_that_mail_was_sent (request ,'In production, email would have been sent' ,msg ,bcc )
257+
241258 if test_mode or debugging or settings .SERVER_MODE == 'production' :
242259 try :
243260 send_smtp (msg ,bcc )
244261 except smtplib .SMTPException as e :
245262 log_smtp_exception (e )
246263 build_warning_message (request , e )
247264 send_error_email (e )
265+
266+ show_that_mail_was_sent (request ,'Email was sent' ,msg ,bcc )
248267
249268 elif settings .SERVER_MODE == 'test' :
250269 if toUser :
0 commit comments