Last active
May 11, 2018 22:15
-
-
Save x011/eb3d193213f5240bb74bcc2d0854ea74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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