【问题标题】:Gmail SMTP authentication always failGmail SMTP 身份验证总是失败
【发布时间】:2019-03-14 06:18:07
【问题描述】:

我在 python 3 中创建了这个软件

import smtplib
TO = 'anywhere@mail.com'
SUBJECT = 'Text subject of the mail'
TEXT = 'Text of the mail'

gmail_sender = 'yourMail@gmail.com'
gmail_passwd = 'password'
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login(gmail_sender, gmail_passwd)
BODY = '\r\n'.join(['To: %s' % TO,
                    'From: %s' % gmail_sender,
                    'Subject: %s' % SUBJECT,
                    '', TEXT])
try:
    server.sendmail(gmail_sender, [TO], BODY)
    print ('email sent')
except:
    print ('error sending mail')
server.quit()

该软件第一天运行良好,但现在我总是收到来自 gmail 的身份验证错误:

   smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more at\n5.7.8  https://support.google.com/mail/?p=BadCredentials o81-v6sm9180362wmo.38 - gsmtp')

我已经做的是:

我从此链接停用了解锁验证码:

https://accounts.google.com/DisplayUnlockCaptcha

我已通过此链接启用安全性较低的应用:

https://www.google.com/settings/security/lesssecureapps

但还是一样,我不能再发送电子邮件了。似乎没有 Python 软件问题,因为我在 Go 中编写了相同的软件,但仍然收到相同的错误。

【问题讨论】:

    标签: python authentication go smtp gmail


    【解决方案1】:

    解决了。我的登录错误。

    【讨论】:

      猜你喜欢
      • 2013-02-06
      • 2022-08-17
      • 2018-06-23
      • 2012-06-16
      • 2016-06-23
      • 2016-02-13
      • 2011-10-09
      • 2015-10-14
      • 2014-07-21
      相关资源
      最近更新 更多