From 015a10637b8e4f9e5905cf074d27be6b8d1fd480 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Mon, 27 Feb 2023 17:19:32 +0000 Subject: [PATCH] docs: Document how to use SMTP without authentication. This is the behaviour inherited from Django[^1]. While setting the password to empty (`email_password = `) in `/etc/zulip/zulip-secrets.conf` also would suffice, it's unclear what the user would have been putting into `EMAIL_HOST_USER` in that context. Because we previously did not warn when `email_password` was not present in `zulip-secrets.conf`, having the error message clarify the correct configuration for disabling SMTP auth is important. Fixes: #23938. [^1]: https://docs.djangoproject.com/en/4.1/ref/settings/#std-setting-EMAIL_HOST_USER --- docs/production/email.md | 4 +++- zerver/lib/send_email.py | 3 ++- zerver/tests/test_send_email.py | 3 ++- zproject/prod_settings_template.py | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/production/email.md b/docs/production/email.md index 55116e4799..e0bd38cb02 100644 --- a/docs/production/email.md +++ b/docs/production/email.md @@ -12,7 +12,9 @@ email addresses and send notifications. 1. Fill out the section of `/etc/zulip/settings.py` headed "Outgoing email (SMTP) settings". This includes the hostname and typically the port to reach your SMTP provider, and the username to log in to - it. You'll also want to fill out the noreply email section. + it. If your SMTP server does not require authentication, leave + `EMAIL_HOST_USER` empty. You'll also want to fill out the noreply + email section. 1. Put the password for the SMTP user account in `/etc/zulip/zulip-secrets.conf` by setting `email_password`. For diff --git a/zerver/lib/send_email.py b/zerver/lib/send_email.py index 74db535f70..17637bb246 100644 --- a/zerver/lib/send_email.py +++ b/zerver/lib/send_email.py @@ -599,5 +599,6 @@ def log_email_config_errors() -> None: """ if settings.EMAIL_HOST_USER and settings.EMAIL_HOST_PASSWORD is None: logger.error( - "An SMTP username was set (EMAIL_HOST_USER), but password is unset (EMAIL_HOST_PASSWORD)." + "An SMTP username was set (EMAIL_HOST_USER), but password is unset (EMAIL_HOST_PASSWORD). " + "To disable SMTP authentication, set EMAIL_HOST_USER to an empty string." ) diff --git a/zerver/tests/test_send_email.py b/zerver/tests/test_send_email.py index 3006e36cea..d274a3e70a 100644 --- a/zerver/tests/test_send_email.py +++ b/zerver/tests/test_send_email.py @@ -165,7 +165,8 @@ class TestSendEmail(ZulipTestCase): error_log.output, [ "ERROR:zulip.send_email:" - "An SMTP username was set (EMAIL_HOST_USER), but password is unset (EMAIL_HOST_PASSWORD)." + "An SMTP username was set (EMAIL_HOST_USER), but password is unset (EMAIL_HOST_PASSWORD). " + "To disable SMTP authentication, set EMAIL_HOST_USER to an empty string." ], ) diff --git a/zproject/prod_settings_template.py b/zproject/prod_settings_template.py index 157cf8e287..68f6d504b5 100644 --- a/zproject/prod_settings_template.py +++ b/zproject/prod_settings_template.py @@ -71,7 +71,9 @@ EXTERNAL_HOST = "zulip.example.com" ## advice for troubleshooting, see the Zulip documentation: ## https://zulip.readthedocs.io/en/latest/production/email.html -## EMAIL_HOST and EMAIL_HOST_USER are generally required. +## EMAIL_HOST and EMAIL_HOST_USER are generally required. If your +## SMTP server does not require authentication, leave EMAIL_HOST_USER +## commented out. # EMAIL_HOST = "smtp.example.com" # EMAIL_HOST_USER = ""