Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

email: Catch OSError when sending emails, to handle SMTP firewalls.

Alex Vandiver1e8f57e9083e
diff --git a/zerver/management/commands/send_test_email.py b/zerver/management/commands/send_test_email.py
index 92d819fb157..ab69063ede9 100644
--- a/zerver/management/commands/send_test_email.py
+++ b/zerver/management/commands/send_test_email.py
@@ -61,6 +61,16 @@ class Command(sendtestemail.Command):
print("Full SMTP log follows:")
print(f.getvalue())
raise CommandError("Email sending failed!")
+ except OSError as e:
+ print(f"Failed to send mails: {e}")
+ print()
+ print("Full SMTP log follows:")
+ print(f.getvalue())
+ print()
+ print(
+ "This usually means that your host or firewall is blocking outgoing SMTP traffic."
+ )
+ raise CommandError("Email sending failed!")
print()
print("Successfully sent 2 emails to {}!".format(", ".join(kwargs["email"])))