我看到很多其他帖子都有同样的问题,我尝试了以下所有方法:
- 允许访问安全性较低的 gmail 应用
- 在谷歌上解锁 token
- 设置应用专用密码
- 在 gmail 上允许 IMAP
没有任何效果,我仍然收到相同的错误消息:
SMTPAuthenticationError: (534, b'5.7.9 Please log in with your web browser and then try again. Learn more at\n5.7.9 https://support.google.com/mail/?p=WebLoginRequired s3sm5978501edm.78 - gsmtp')
这是我在 python jupiter notebook 上的代码:
sender_email = "xxx@gmail.com"
receiver_email = "yyy@gmail.com"
password = "xxxxxx"
message = MIMEMultipart("alternative")
message["Subject"] = "new properties for rent"
message["From"] = sender_email
message["To"] = receiver_email
# Create the plain-text and HTML version of your message
text = "Hi, new properties satisfy your search on daft: %s" % dictionary
html = "<html><body>%s</body></html>" % emailBody
# Turn these into plain/html MIMEText objects
part1 = MIMEText(text, "plain")
part2 = MIMEText(html, "html")
# Add HTML/plain-text parts to MIMEMultipart message
# The email client will try to render the last part first
message.attach(part1)
message.attach(part2)
# Create secure connection with server and send email
context = ssl.create_default_context()
with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server:
server.ehlo()
server.login(sender_email, password)
server.sendmail(
sender_email, receiver_email, message.as_string()
)
最佳答案
这有几个原因。
但是,由于您已经用尽了其中的大部分,并且在评论中进行了讨论。很明显,您使用的是某种 VPN 或共享互联网连接。
有时,通过此 VPN/共享连接在浏览器中登录您的帐户可以解决问题。如果没有,最快和最简单的解决方法是切换到单用户连接(家庭 wifi、专用 VPS,可能只有少数用户坐在的地方)。
常见问题是:您使用的是 Tor,一种流行的 VPN 提供商,学校/公司网络。
以下是关于该主题的更多信息:
关于python - smtp错误534连接到gmail python3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54944432/