Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
send_email: Be sure to close connection on email sending failure.
Alex Vandiverc0c3a583fed4
diff --git a/zerver/lib/send_email.py b/zerver/lib/send_email.pyindex 4f63064f5a5..fd34bc8db40 100644--- a/zerver/lib/send_email.py+++ b/zerver/lib/send_email.py@@ -325,6 +325,7 @@ def send_immediate_email(# it will only call .close() if it was not open to begin withif connection.send_messages([mail]) == 0:logger.error("Unknown error sending %s email to %s", template, mail.to)+ connection.close()raise EmailNotDeliveredErrorexcept smtplib.SMTPResponseException as e:logger.exception(@@ -335,9 +336,11 @@ def send_immediate_email(e.smtp_error,stack_info=True,)+ connection.close()raise EmailNotDeliveredErrorexcept smtplib.SMTPException as e:logger.exception("Error sending %s email to %s: %s", template, mail.to, e, stack_info=True)+ connection.close()raise EmailNotDeliveredError