Skip to content

Commit

Permalink
[Bugfix] (libs.utils): 🐛587 端口使用 starttls 方法
Browse files Browse the repository at this point in the history
Fix #424
  • Loading branch information
a76yyyy committed Feb 10, 2024
1 parent 68aa0b7 commit 64e3fba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions libs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 64e3fba

Please sign in to comment.