获取错误:服务器Python3不支持SMTP身份验证扩展
当我用获取错误:服务器Python3不支持SMTP身份验证扩展,python,python-3.x,smtp,Python,Python 3.x,Smtp,当我用server=smtplib.SMTP('smpt.gmail.com:587')测试下面的代码时,它工作得很好 但是当我将SMTP服务器更改为server=smtplib.SMTP('10.10.9.9:25'),它会给我一个错误。此SMTP不需要任何密码 那么我在这里错过了什么 import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart import
server=smtplib.SMTP('smpt.gmail.com:587')
测试下面的代码时,它工作得很好
但是当我将SMTP服务器更改为server=smtplib.SMTP('10.10.9.9:25')
,它会给我一个错误。此SMTP不需要任何密码
那么我在这里错过了什么
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import pandas as pd
def send_email(user, recipient, subject):
try:
d = {'Col1':[1,2], 'Col2':[3,4]}
df=pd.DataFrame(d)
df_html = df.to_html()
dfPart = MIMEText(df_html,'html')
user = "myEmail@gmail.com"
#pwd = No need for password with this SMTP
subject = "Test subject"
recipients = "some_recipientk@blabla.com"
#Container
msg = MIMEMultipart('alternative')
msg['Subject'] = subject
msg['From'] = user
msg['To'] = ",".join(recipients)
msg.attach(dfPart)
#server = smtplib.SMTP('smpt.gmail.com:587') #this works
server = smtplib.SMTP('10.10.9.9: 25') #this doesn't work
server.starttls()
server.login(user, pwd)
server.sendmail(user, recipients, msg.as_string())
server.close()
print("Mail sent succesfully!")
except Exception as e:
print(str(e))
print("Failed to send email")
send_email(user,"","Test Subject")
如果服务器不需要身份验证,则不要使用SMTP身份验证 删除以下行:
server.login(用户,pwd)
如果服务器不需要身份验证,则不要使用SMTP身份验证
删除以下行:server.login(user,pwd)
您好,我不完全确定它为什么不工作,但我有一些东西可以检查
- server=smtplib.SMTP('10.10.9.9:25')
ip:端口字符串中有空格,请尝试删除它。 - ip:端口组合似乎来自专用LAN地址
尝试ping此地址以查看是否可以访问,如果无法访问,则与网络中具有给定ip的机器操作人员交谈。
如果您可以ping ip,则可能是SMTP服务器在给定端口上不可用,在这种情况下,请与负责使用ip管理计算机的人员联系:10.10.9.9 在终端上使用给定命令
平10.10.9.9
- 同样在登录和发送邮件之前,您应该使用connect()连接到服务器,正确的顺序是
server=smtplib.SMTP('10.10.9.9:25')
server.starttls()
server.connect('10.10.9.9',465)
服务器登录(用户,pwd)
server.sendmail(用户、收件人、msg.as_string())
server.close()
如果对你有帮助,请告诉我 嗨,我不太清楚它为什么不起作用,但我有一些东西你可以检查一下
- server=smtplib.SMTP('10.10.9.9:25')
ip:端口字符串中有空格,请尝试删除它。 - ip:端口组合似乎来自专用LAN地址
尝试ping此地址以查看是否可以访问,如果无法访问,则与网络中具有给定ip的机器操作人员交谈。
如果您可以ping ip,则可能是SMTP服务器在给定端口上不可用,在这种情况下,请与负责使用ip管理计算机的人员联系:10.10.9.9 在终端上使用给定命令
平10.10.9.9
- 同样在登录和发送邮件之前,您应该使用connect()连接到服务器,正确的顺序是
server=smtplib.SMTP('10.10.9.9:25')
server.starttls()
server.connect('10.10.9.9',465)
服务器登录(用户,pwd)
server.sendmail(用户、收件人、msg.as_string())
server.close()
如果对你有帮助,请告诉我 刚试过。但仍然遇到同样的错误。谢谢你,我试过了。但仍然遇到同样的错误。谢谢