我想从python脚本发送一封电子邮件。但是,当我尝试运行server.login
时,收到以下错误:smtplib.SMTPAuthenticationError: (535, '5.7.0 (#MBR1212) Incorrect username or password.')
我已尝试使用Gmail和Yahoo帐户。 Gmail错误是:
smtplib.SMTPAuthenticationError: (535, '5.7.8 Username and Password not accepted. Learn more at\n5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 u2sm21203448pbs.42 \
- gsmtp')
雅虎错误
smtplib.SMTPAuthenticationError: (535, '5.7.0 (#MBR1212) Incorrect username or password.')
我正在使用的代码如下。用户名和密码是表示我的正确用户名和密码的字符串变量。
server = smtplib.SMTP('smtp.mail.yahoo.com', 587)
server.ehlo()
server.starttls()
server.login(username, password)
我正在使用Python 2.7.6 |Anaconda 1.8.0 (x86_64)| (default, May 27 2014, 14:58:54)
答案 0 :(得分:5)
您应该访问雅虎电子邮件帐户,然后转到Account security
并激活Allow apps that use less secure sign in
以解决您的问题。