0

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') 
3
  • did you follow all "Troubleshoot" tips in the link of the error message? Have you tried using your login data with a standalone email client? Commented Apr 30, 2020 at 8:02
  • yes sir, I tried Commented Apr 30, 2020 at 8:25
  • 1
    and did it work? I tried your exact code (except ssl instead of SSL) after creating an app specific password at myaccount.google.com/apppasswords and everything just worked.. Commented Apr 30, 2020 at 8:43

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes Sir, Now It Worked .. I Enabled 2 Step Verification and App Password Got enabled and Now I can use it

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.