diff --git a/docs/installation.rst b/docs/installation.rst index 7c06bbb..f8e48e8 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -218,6 +218,9 @@ with the password ``my:password``, it would be represented as:: smtp://someone%40example.com:my%3Apassword@smtp.example.com:25/ +The username and password can be omitted, with a URL in the form +``smtp://host:port/``, if your mail server is a (properly firewalled!) +unauthenticated relay. SendGrid ######## diff --git a/takahe/settings.py b/takahe/settings.py index 3d7f0c4..28e512b 100644 --- a/takahe/settings.py +++ b/takahe/settings.py @@ -395,8 +395,10 @@ if SETUP.EMAIL_SERVER: elif parsed.scheme == "smtp": EMAIL_HOST = parsed.hostname EMAIL_PORT = parsed.port - EMAIL_HOST_USER = urllib.parse.unquote(parsed.username) - EMAIL_HOST_PASSWORD = urllib.parse.unquote(parsed.password) + if parsed.username is not None: + EMAIL_HOST_USER = urllib.parse.unquote(parsed.username) + if parsed.password is not None: + EMAIL_HOST_PASSWORD = urllib.parse.unquote(parsed.password) EMAIL_USE_TLS = as_bool(query.get("tls")) EMAIL_USE_SSL = as_bool(query.get("ssl")) else: