From fd01ddd215059d5eacaed7772db842fa316aa106 Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Fri, 15 Nov 2013 12:57:31 +0000 Subject: [PATCH] Make the mail code detect USING_DEBUG_EMAIL_SERVER which if set to true and EMAIL_HOST and EMAIL_PORT is set to localhost:1025 will turn on debugging which essentially makes it send emails; also added instructions for starting the debugging SMTP server bundled with Python python -m smtpd -n -c DebuggingServer localhost:1025 in a comment near the code - Legacy-Id: 6713 --- ietf/utils/mail.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ietf/utils/mail.py b/ietf/utils/mail.py index a99962b36..f53945825 100644 --- a/ietf/utils/mail.py +++ b/ietf/utils/mail.py @@ -176,8 +176,13 @@ def send_mail_mime(request, to, frm, subject, msg, cc=None, extra=None, toUser=F if extra: for k, v in extra.items(): if v: - msg[k] = v - if test_mode or settings.SERVER_MODE == 'production': + msg[k] = v + # start debug server with python -m smtpd -n -c DebuggingServer localhost:1025 + # then put USING_DEBUG_EMAIL_SERVER=True and EMAIL_HOST='localhost' + # and EMAIL_PORT=1025 in settings_local.py + debugging = getattr(settings, "USING_DEBUG_EMAIL_SERVER", False) and settings.EMAIL_HOST == 'localhost' and settings.EMAIL_PORT == 1025 + + if test_mode or debugging or settings.SERVER_MODE == 'production': send_smtp(msg, bcc) elif settings.SERVER_MODE == 'test': if toUser: @@ -188,7 +193,7 @@ def send_mail_mime(request, to, frm, subject, msg, cc=None, extra=None, toUser=F copy_to = settings.EMAIL_COPY_TO except AttributeError: copy_to = "ietf.tracker.archive+%s@gmail.com" % settings.SERVER_MODE - if copy_to and not test_mode: # if we're running automated tests, this copy is just annoying + if copy_to and not test_mode and not debugging: # if we're running automated tests, this copy is just annoying if bcc: msg['X-Tracker-Bcc']=bcc copy_email(msg, copy_to,originalBcc=bcc)