-2

I want to test whether the password entered by the user of his google account is correct or not, but I am always getting INCORRECT as an output

How do I perform this?

Before asking this question I've tried :

import smtplib as s

ID = input("ENTER YOUR MAIL ID")
PASSW = input("pass")

server = s.SMTP("smtp.gmail.com", 587)
server.starttls()

a = server.login(ID,PASSW)

if a == True:
    print("CORRECT")
else:
    print("INCORRECT")

server.quit()
CopyrightC
  • 857
  • 2
  • 7
  • 15
  • 1
    Google does not like that kind of behaviour and might block the user and your IP rather quickly. Also by default Google does not allow SMTP via username/password for a user. – Klaus D. Jul 01 '20 at 07:27
  • Welcome to Stack Overflow. Please take the [tour](https://stackoverflow.com/tour), read about what's on-topic in the [help center](https://stackoverflow.com/help/on-topic), and read [How to Ask a Good Question](https://stackoverflow.com/help/how-to-ask). In particular take the time to format your question and code if you expect other people to help you. – Ivo Mori Jul 01 '20 at 07:48

1 Answers1

1

This should work just make sure Less secure app is enabled

import smtplib as s

ID = '' #your mail
PASSW = input("pass : ")

server = s.SMTP("smtp.gmail.com", 587)
server.starttls()
try:
    server.login(ID,PASSW)
except SMTPAuthenticationError:
    print("Password is wrong")

server.quit()