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
This commit is contained in:
Ole Laursen 2013-11-15 12:57:31 +00:00
parent 322e15e9a9
commit fd01ddd215

View file

@ -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)