summary refs log tree commit diff
path: root/synapse/config
diff options
context:
space:
mode:
authorJan Schär <jan@jschaer.ch>2022-07-25 17:27:19 +0200
committerGitHub <noreply@github.com>2022-07-25 16:27:19 +0100
commite8519e0ed289b67fa07c1bdbb6898852dc1a50b9 (patch)
treec43eaafeef1b50506cbd23425071dbaaa27106dd /synapse/config
parentAdditional fixes for opentracing type hints. (#13362) (diff)
downloadsynapse-e8519e0ed289b67fa07c1bdbb6898852dc1a50b9.tar.xz
Support Implicit TLS for sending emails (#13317)
Previously, TLS could only be used with STARTTLS.
Add a new option `force_tls`, where TLS is used from the start.
Implicit TLS is recommended over STARTLS,
see https://datatracker.ietf.org/doc/html/rfc8314

Fixes #8046.

Signed-off-by: Jan Schär <jan@jschaer.ch>
Diffstat (limited to 'synapse/config')
-rw-r--r--synapse/config/emailconfig.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/synapse/config/emailconfig.py b/synapse/config/emailconfig.py
index 3ead80d985..73b469f414 100644
--- a/synapse/config/emailconfig.py
+++ b/synapse/config/emailconfig.py
@@ -85,14 +85,19 @@ class EmailConfig(Config):
         if email_config is None:
             email_config = {}
 
+        self.force_tls = email_config.get("force_tls", False)
         self.email_smtp_host = email_config.get("smtp_host", "localhost")
-        self.email_smtp_port = email_config.get("smtp_port", 25)
+        self.email_smtp_port = email_config.get(
+            "smtp_port", 465 if self.force_tls else 25
+        )
         self.email_smtp_user = email_config.get("smtp_user", None)
         self.email_smtp_pass = email_config.get("smtp_pass", None)
         self.require_transport_security = email_config.get(
             "require_transport_security", False
         )
         self.enable_smtp_tls = email_config.get("enable_tls", True)
+        if self.force_tls and not self.enable_smtp_tls:
+            raise ConfigError("email.force_tls requires email.enable_tls to be true")
         if self.require_transport_security and not self.enable_smtp_tls:
             raise ConfigError(
                 "email.require_transport_security requires email.enable_tls to be true"