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
This commit is contained in:
Alex Vandiver 2023-02-27 17:19:32 +00:00 committed by Tim Abbott
parent caab470656
commit 015a10637b
4 changed files with 10 additions and 4 deletions

View File

@ -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

View File

@ -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."
)

View File

@ -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."
],
)

View File

@ -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 = ""