Skip to content

Instantly share code, notes, and snippets.

@x011
Last active May 11, 2018 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x011/eb3d193213f5240bb74bcc2d0854ea74 to your computer and use it in GitHub Desktop.
Save x011/eb3d193213f5240bb74bcc2d0854ea74 to your computer and use it in GitHub Desktop.
# Make sure less secure apps access is enabled on your gmail account.
# https://support.google.com/accounts/answer/6010255?hl=en
def gmail_checker(username,password):
import imaplib
i=imaplib.IMAP4_SSL('imap.gmail.com')
try:
i.login(username,password)
if i.welcome and "OK Gimap" in i.welcome :
return True
except:
return
# Use in your scripts as follows:
if ( gmail_checker('user','pass')) :
print("Valid Credentials")
else:
print("Invalid Credentials")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment