Skip to content

Instantly share code, notes, and snippets.

@evansd
Created February 4, 2020 15:43
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 evansd/cb2658d0e2277f64bbee20e7394dcf5a to your computer and use it in GitHub Desktop.
Save evansd/cb2658d0e2277f64bbee20e7394dcf5a to your computer and use it in GitHub Desktop.
Use the flanker library to get all the bad email addresses included in the list supplied on stdin
#!/usr/bin/env python
# pip install flanker dnsq
#
# requirements.txt:
# attrs==19.3.0
# cffi==1.13.2
# chardet==3.0.4
# cryptography==2.8
# dnspython==1.16.0
# dnsq==1.1.6
# expiringdict==1.2.0
# flanker==0.9.11
# idna==2.8
# pkg-resources==0.0.0
# ply==3.11
# pycparser==2.19
# regex==2020.1.8
# six==1.14.0
# tld==0.11.9
# typing==3.7.4.1
# WebOb==1.8.6
from collections import defaultdict
import sys
import flanker.addresslib
from flanker.addresslib import address
flanker.addresslib.set_mx_cache(defaultdict(lambda: None))
if __name__ == '__main__':
for email in sys.stdin:
email = email.strip()
if not email:
continue
if not address.validate_address(email):
print(email)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment