mirror of
https://github.com/simple-login/app.git
synced 2024-11-13 07:31:12 +01:00
Fix: Only override postfix port when enabling TLS if the port is set to be 25 (#1401)
* Fix: Only override postfix port when enabling TLS if the port is set to be 25 * Add connection timeout Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
parent
dace2b1233
commit
5bbf6a2654
2 changed files with 4 additions and 5 deletions
|
@ -111,13 +111,12 @@ POSTFIX_SERVER = os.environ.get("POSTFIX_SERVER", "240.0.0.1")
|
|||
DISABLE_REGISTRATION = "DISABLE_REGISTRATION" in os.environ
|
||||
|
||||
# allow using a different postfix port, useful when developing locally
|
||||
POSTFIX_PORT = 25
|
||||
if "POSTFIX_PORT" in os.environ:
|
||||
POSTFIX_PORT = int(os.environ["POSTFIX_PORT"])
|
||||
POSTFIX_PORT = int(os.environ.get("POSTFIX_PORT", 25))
|
||||
|
||||
# Use port 587 instead of 25 when sending emails through Postfix
|
||||
# Useful when calling Postfix from an external network
|
||||
POSTFIX_SUBMISSION_TLS = "POSTFIX_SUBMISSION_TLS" in os.environ
|
||||
POSTFIX_TIMEOUT = os.environ.get("POSTFIX_TIMEOUT", 3)
|
||||
|
||||
# ["domain1.com", "domain2.com"]
|
||||
OTHER_ALIAS_DOMAINS = sl_getenv("OTHER_ALIAS_DOMAINS", list)
|
||||
|
|
|
@ -117,13 +117,13 @@ class MailSender:
|
|||
return True
|
||||
|
||||
def _send_to_smtp(self, send_request: SendRequest, retries: int) -> bool:
|
||||
if config.POSTFIX_SUBMISSION_TLS:
|
||||
if config.POSTFIX_SUBMISSION_TLS and config.POSTFIX_PORT == 25:
|
||||
smtp_port = 587
|
||||
else:
|
||||
smtp_port = config.POSTFIX_PORT
|
||||
try:
|
||||
start = time.time()
|
||||
with SMTP(config.POSTFIX_SERVER, smtp_port) as smtp:
|
||||
with SMTP(config.POSTFIX_SERVER, smtp_port, config.POSTFIX_TIMEOUT) as smtp:
|
||||
if config.POSTFIX_SUBMISSION_TLS:
|
||||
smtp.starttls()
|
||||
|
||||
|
|
Loading…
Reference in a new issue