Fix: SMTP Port 465 SSL statt 587 STARTTLS (Port 587 von Synology geblockt)

This commit is contained in:
rene 2026-05-06 20:23:45 +02:00
parent e4b661222c
commit a666efd25f

View file

@ -116,11 +116,16 @@ def _send_smtp(to: str, subject: str, body: str, account: str = "partner", html:
msg = _build_message(to, subject, body + _LEGAL_FOOTER, account, html=html)
msg_bytes = msg.as_bytes()
ctx = ssl.create_default_context()
with smtplib.SMTP(_SMTP_HOST, _SMTP_PORT, timeout=15) as s:
s.ehlo()
s.starttls(context=ctx)
s.login(acc["user"], acc["pass"])
s.sendmail(acc["from"], [to], msg_bytes)
if _SMTP_PORT == 465:
with smtplib.SMTP_SSL(_SMTP_HOST, _SMTP_PORT, context=ctx, timeout=15) as s:
s.login(acc["user"], acc["pass"])
s.sendmail(acc["from"], [to], msg_bytes)
else:
with smtplib.SMTP(_SMTP_HOST, _SMTP_PORT, timeout=15) as s:
s.ehlo()
s.starttls(context=ctx)
s.login(acc["user"], acc["pass"])
s.sendmail(acc["from"], [to], msg_bytes)
_imap_save_sent(msg_bytes, account)