从代理后面发送电子邮件时出现HTTP身份验证错误

2024-04-25 16:59:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用下面的python代码 HTTPError:407:需要身份验证

我正在传递正确的电子邮件id和密码,但问题仍然存在。你知道我为什么会看到这个错误吗

socks.set_default_proxy(socks.HTTP,'proxy.proxy.com',9090,True,userid,pwd)
socks.wrapmodule(smtplib)

smtp_server = "smtp.gmail.com"
port = 587
sender_email = "abc@gmail.com"
password = "pwd"
message = "Test message from python"
server = smtplib.SMTP(smtp_server,port)
server.starttls()
server.login(sender_email,password)
server.sendmail(sender_email, "xxx@gmail.com", message)
server.quit()

Tags: 代码commessageserverportemailpwdpassword