问题描述
我正在使用以下代码,但是我一直收到错误消息..我在做什么错了。
import os
import smtplib
sender_email = "[email protected]"
rec_email = "[email protected]"
username = "[email protected]"
password = input(str("EnterPassword"))
message = "Hey,this was sent using python"
server = smtplib.SMTP('smtp.gmail.com',587)
server.starttls()
print("connected")
server.login(username,password)
print("Login success")
server.sendmail(sender_email,rec_email,message)
print("Email has been sent")
错误:
connected
Traceback (most recent call last):
File "C:/Users/<user>/PycharmProjects/Report/main.py",line 12,in <module>
server.login(username,password)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\smtplib.py",line 730,in login
raise last_exception
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\smtplib.py",line 721,in login
initial_response_ok=initial_response_ok)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\smtplib.py",line 642,in auth
raise SMTPAuthenticationError(code,resp)
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 q15sm575467pje.29 - gsmtp')
Process finished with exit code 1
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)