From d59c209c562292eb19f21eb11ffe7a366c839b3c Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Thu, 27 Feb 2014 17:57:03 -0800 Subject: [PATCH] emails: Reject sending emails with header parse errors. Thanks to Jordan Milne (/u/largenocream) for backing up our email queues^W^W^W^W^W bringing this to our attention. ;) --- r2/r2/lib/emailer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/r2/r2/lib/emailer.py b/r2/r2/lib/emailer.py index 31a4382b1..50d1b7842 100644 --- a/r2/r2/lib/emailer.py +++ b/r2/r2/lib/emailer.py @@ -21,6 +21,7 @@ ############################################################################### from email.MIMEText import MIMEText +from email.errors import HeaderParseError import datetime import traceback, sys, smtplib @@ -177,7 +178,7 @@ def send_queued_mail(test = False): email.set_sent(rejected = False) # exception happens only for local recipient that doesn't exist except (smtplib.SMTPRecipientsRefused, smtplib.SMTPSenderRefused, - UnicodeDecodeError, AttributeError): + UnicodeDecodeError, AttributeError, HeaderParseError): # handle error and print, but don't stall the rest of the queue print "Handled error sending mail (traceback to follow)" traceback.print_exc(file = sys.stdout)