【发布时间】: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