-
-
Save tejastank/88d38025af20f499f8683876a6518d46 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
#!/usr/bin/env python3 | |
""" | |
DESCRIPTION | |
Email checker | |
INSTALL | |
sudo apt-get install python3-pip | |
pip3 install validate_email | |
pip3 install py3DNS | |
chmod 755 check.py | |
./check.py --validate [email protected] --debug | |
DEBUG:validate_email:mx1.hot.ee answer: 550 - b'5.1.1 <[email protected]>: Recipient address rejected: User unknown in relay recipient table' | |
I'm not sure. | |
./check.py --mx --validate [email protected] --debug | |
[email protected] is valid! | |
""" | |
from validate_email import validate_email | |
import logging | |
import argparse | |
def main(args): | |
if args.debug: | |
logging.basicConfig() | |
result = validate_email(args.rcpt,check_mx=args.mx,verify=args.validate,debug=args.debug, smtp_timeout=args.timeout) | |
if result: | |
print("%s is valid!" % args.rcpt) | |
elif result is None: | |
print("I'm not sure.") | |
else: | |
print("%s is invalid!" % args.rcpt) | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description='email checker') | |
parser.add_argument('rcpt',help='SMTP rcpt to:' ) | |
parser.add_argument('--mx', action='store_true', default=False,help='MX check' ) | |
parser.add_argument('--validate', action='store_true', default=False,help='Validate check') | |
parser.add_argument('--smtp_timeout',dest='timeout',type=int, default=10,help='SMTP timeout' ) | |
parser.add_argument('--debug', action='store_true', default=False,help='DEBUG output' ) | |
args = parser.parse_args() | |
main(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment