diff --git a/libs/utils.py b/libs/utils.py index b321b0994a2..3107452eec7 100644 --- a/libs/utils.py +++ b/libs/utils.py @@ -455,6 +455,11 @@ async def _send_mail(to, subject, text=None, subtype='html'): if config.mail_port: if config.mail_ssl or config.mail_port in [465, 587]: s = smtplib.SMTP_SSL(config.mail_smtp, config.mail_port) + if config.mail_port == 587: # use starttls + try: + s.starttls() + except smtplib.SMTPException as e: + logger_util.error("smtp starttls failed: %s", e, exc_info=config.traceback_print) else: s = smtplib.SMTP(config.mail_smtp, config.mail_port) s.connect(config.mail_smtp, config.mail_port)