gate4: fix SMTP TLS mode for port 465 (implicit TLS instead of STARTTLS)
This commit is contained in:
+5
-2
@@ -133,14 +133,17 @@ async def send_password_reset_email(
|
|||||||
msg.attach(MIMEText(text_body, "plain", "utf-8"))
|
msg.attach(MIMEText(text_body, "plain", "utf-8"))
|
||||||
msg.attach(MIMEText(html_body, "html", "utf-8"))
|
msg.attach(MIMEText(html_body, "html", "utf-8"))
|
||||||
|
|
||||||
# Send via SMTP
|
# Send via SMTP (port 465 = implicit TLS, port 587 = STARTTLS)
|
||||||
|
use_tls = settings.smtp_port == 465
|
||||||
|
start_tls = settings.smtp_use_tls and not use_tls
|
||||||
await aiosmtplib.send(
|
await aiosmtplib.send(
|
||||||
msg,
|
msg,
|
||||||
hostname=settings.smtp_host,
|
hostname=settings.smtp_host,
|
||||||
port=settings.smtp_port,
|
port=settings.smtp_port,
|
||||||
username=settings.smtp_username,
|
username=settings.smtp_username,
|
||||||
password=settings.smtp_password,
|
password=settings.smtp_password,
|
||||||
start_tls=settings.smtp_use_tls,
|
use_tls=use_tls,
|
||||||
|
start_tls=start_tls,
|
||||||
)
|
)
|
||||||
logger.info("Password reset email sent to %s for user %s", email, user_id)
|
logger.info("Password reset email sent to %s for user %s", email, user_id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user