Reputation: 307
I got a problem with my python program. I Have entered the correct information about my email and password the program and the error is shown below
import smtplib, SSL
email="[email protected]"
password="my password"
port = 465
context = ssl.create_default_context()
server =smtplib.SMTP_SSL("smtp.gmail.com",port,context=context)
server.login(email,password)
message=" Hi I Am Belgin Android "
sender_mail=email,
receiver_email="[email protected]"
server.sendmail(sender_mail,receiver_email,message)
Error:
Traceback (most recent call last):
File "c:/Users/Belgin/Desktop/Python Coding/email_sending.py", line 10, in <module>
server.login(email,password)
File "G:\Python\lib\smtplib.py", line 734, in login
raise last_exception
File "G:\Python\lib\smtplib.py", line 723, in login
(code, resp) = self.auth(
File "G:\Python\lib\smtplib.py", line 646, 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 f21sm2590687pfn.71 - gsmtp')
Upvotes: 0
Views: 1946
Reputation: 4893
To sum it up - I guess the problem was that Google does not allow you to log in with your default user password, especially (but not only) when using 2nd factor authentication. So for using the password for 3rd party apps it requires creating app specific passwords.
Upvotes: 2