我正在尝试使用smtplib发送邮件,我得到了如下错误,我搜索了有关此错误的其他主题,但我找不到解决方案。有人可以帮助我吗?法典:import smtplibfrom email.mime.multipart import MIMEMultipartfrom email.mime.text import MIMETextfrom email.mime.base import MIMEBasefrom email import encoderstoaddr = "mailto@mail.com"head = "TRY" body = "XxX"fromaddr = "mailsender@mail.com"msg = MIMEMultipart()msg['From'] = fromaddrmsg['To'] = toaddrmsg['Subject'] = headpassword = "password"msg.attach(MIMEText(body, 'plain'))server = smtplib.SMTP('SMTP', 25)server.connect('SMTP', 25)server.starttls()server.ehlo()server.login(fromaddr, password)text = msg.as_string()server.sendmail(fromaddr, toaddr, text)server.quit()错误:SMTPNotSupportedError Traceback (most recent call last)<ipython-input-4-357dd2da8ab1> in <module> 17 server = smtplib.SMTP('mailenable', 25) 18 server.connect('mailenable', 25) ---> 19 server.starttls() 20 server.ehlo() 21 server.login(fromaddr, password) /opt/anaconda/envs/env_python/lib/python3.6/smtplib.py in starttls(self, keyfile, certfile, context) 750 if not self.has_extn("starttls"): 751 raise SMTPNotSupportedError( --> 752 "STARTTLS extension not supported by server.") 753 (resp, reply) = self.docmd("STARTTLS") 754 if resp == 220: SMTPNotSupportedError: STARTTLS extension not supported by server.
1 回答
扬帆大鱼
TA贡献1799条经验 获得超9个赞
弄清楚了这个问题。只需删除此行。
server.starttls()
server.ehlo()
server.login(fromaddr, password)
添加回答
举报
0/150
提交
取消