Skip to content

Commit fd01ddd

Browse files
committed
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
1 parent 322e15e commit fd01ddd

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

ietf/utils/mail.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,13 @@ def send_mail_mime(request, to, frm, subject, msg, cc=None, extra=None, toUser=F
176176
if extra:
177177
for k, v in extra.items():
178178
if v:
179-
msg[k] = v
180-
if test_mode or settings.SERVER_MODE == 'production':
179+
msg[k] = v
180+
# start debug server with python -m smtpd -n -c DebuggingServer localhost:1025
181+
# then put USING_DEBUG_EMAIL_SERVER=True and EMAIL_HOST='localhost'
182+
# and EMAIL_PORT=1025 in settings_local.py
183+
debugging = getattr(settings, "USING_DEBUG_EMAIL_SERVER", False) and settings.EMAIL_HOST == 'localhost' and settings.EMAIL_PORT == 1025
184+
185+
if test_mode or debugging or settings.SERVER_MODE == 'production':
181186
send_smtp(msg, bcc)
182187
elif settings.SERVER_MODE == 'test':
183188
if toUser:
@@ -188,7 +193,7 @@ def send_mail_mime(request, to, frm, subject, msg, cc=None, extra=None, toUser=F
188193
copy_to = settings.EMAIL_COPY_TO
189194
except AttributeError:
190195
copy_to = "ietf.tracker.archive+%s@gmail.com" % settings.SERVER_MODE
191-
if copy_to and not test_mode: # if we're running automated tests, this copy is just annoying
196+
if copy_to and not test_mode and not debugging: # if we're running automated tests, this copy is just annoying
192197
if bcc:
193198
msg['X-Tracker-Bcc']=bcc
194199
copy_email(msg, copy_to,originalBcc=bcc)

0 commit comments

Comments
 (0)