Discover the dns server only once

This commit is contained in:
Christophe de Vienne
2014-04-08 12:10:38 +02:00
parent 892f864278
commit 5599863f18

View File

@@ -25,6 +25,7 @@ import socket
try: try:
import DNS import DNS
ServerError = DNS.ServerError ServerError = DNS.ServerError
DNS.DiscoverNameServers()
except ImportError: except ImportError:
DNS = None DNS = None
@@ -123,7 +124,6 @@ def validate_email(email, check_mx=False, verify=False, debug=False, smtp_timeou
if not DNS: if not DNS:
raise Exception('For check the mx records or check if the email exists you must ' raise Exception('For check the mx records or check if the email exists you must '
'have installed pyDNS python package') 'have installed pyDNS python package')
DNS.DiscoverNameServers()
hostname = email[email.find('@') + 1:] hostname = email[email.find('@') + 1:]
mx_hosts = get_mx_ip(hostname) mx_hosts = get_mx_ip(hostname)
if mx_hosts is None: if mx_hosts is None: