修改smtp发送邮件部分,只在25和587开启startls

针对问题,目前使用465端口开启STARTTLS大部分服务器会报错“454 Command not permitted when TLS active”

SMTP 的通用端口使用是:
25 SMTP
25 SMTP STARTTLS
465 SMTP SSL
587 SMTP TLS/STARTTLS
pull/112/head
“haocao” 2018-09-29 11:30:50 +08:00
parent ce112adc87
commit 8f7c2c5b18
1 changed files with 1 additions and 1 deletions

View File

@ -106,7 +106,7 @@ def tp_send_mail(recipient, message, subject=None, sender=None, cc=None, bcc=Non
if dbg_mode: if dbg_mode:
_smtp.set_debuglevel(1) _smtp.set_debuglevel(1)
_smtp.ehlo() _smtp.ehlo()
if _smtp.has_extn("starttls"): if (_port == 25 or _port == 587) and _smtp.has_extn("starttls"):
_smtp.starttls() _smtp.starttls()
else: else:
_smtp = smtplib.SMTP(_server, _port, timeout=10.0) _smtp = smtplib.SMTP(_server, _port, timeout=10.0)