Last active
November 2, 2017 11:44
-
-
Save rjcrystal/5f1bf577105d96f9b4f27969023af285 to your computer and use it in GitHub Desktop.
validate emails using flanker
This file contains hidden or 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
from flanker.addresslib import address | |
import sys | |
if(len(sys.argv)>1): | |
filename="_validated"+sys.argv[1] | |
opo = open(filename, 'w') | |
with open(sys.argv[1]) as f: | |
emails = f.readlines() | |
for email in emails: | |
clean_email=email.strip().replace(',','') | |
stripped_email=address.parse(clean_email,addr_spec_only=True) | |
if(stripped_email!=None): | |
op=address.validate_address(str(stripped_email)) | |
if(op != None): | |
print(stripped_email) | |
opo.write(str(stripped_email)+ '\n') | |
opo.close() | |
else: | |
print("Please specify a file") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment