Skip to content

Commit

Permalink
dnspython added to setup.py; validate_email now handle timeouts in mx…
Browse files Browse the repository at this point in the history
… dns lookups
  • Loading branch information
guglielmo committed Apr 5, 2013
1 parent dd2c7b4 commit 64f8970
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
*.pyc
build
dist
MANIFEST
*.egg-info
*.egg-info
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
keywords = 'email validation verification mx verify',
url = 'http://github.com/openpolis/validate_email',
license = 'LGPL',
)
install_requires = [
"dnspython==1.10.0",
]
)
5 changes: 4 additions & 1 deletion validate_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ def validate_email(email, check_mx=False,verify=False):
if hostname in cache:
mx_hosts = cache[hostname]
else:
cache[hostname] = mx_hosts = dns.resolver.query(hostname, 'MX')
try:
cache[hostname] = mx_hosts = dns.resolver.query(hostname, 'MX')
except dns.exception.Timeout:
return False

for mx in mx_hosts:
try:
Expand Down

0 comments on commit 64f8970

Please sign in to comment.