From 86ae68a53c4ade3603d55133405ea940e12125aa Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Sat, 7 Apr 2012 23:13:13 +0200 Subject: [PATCH] Changed from mx to check_mx --- .gitignore | 1 + README.rst | 4 ++-- validate_email.py | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index b00a4fa..2e33f3a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build dist MANIFEST +*.egg-info \ No newline at end of file diff --git a/README.rst b/README.rst index 7bb8d47..eadca63 100644 --- a/README.rst +++ b/README.rst @@ -36,13 +36,13 @@ Checking domain has SMTP Server Check if the host has SMPT Server:: from validate_email import validate_email - is_valid = validate_email('example@example.com',mx=True) + is_valid = validate_email('example@example.com',check_mx=True) Verify email exists ------------------- -Check if the host has SMPT Server and the email exists in the server:: +Check if the host has SMPT Server and the email really exists:: from validate_email import validate_email is_valid = validate_email('example@example.com',verify=True) diff --git a/validate_email.py b/validate_email.py index 9cfe7c8..38de574 100644 --- a/validate_email.py +++ b/validate_email.py @@ -81,7 +81,7 @@ class ServerError(Exception): pass # A valid address will match exactly the 3.4.1 addr-spec. VALID_ADDRESS_REGEXP = '^' + ADDR_SPEC + '$' -def validate_email(email, mx=False,verify=False): +def validate_email(email, check_mx=False,verify=False): """Indicate whether the given string is a valid email address according to the 'addr-spec' portion of RFC 2822 (see section @@ -92,8 +92,8 @@ def validate_email(email, mx=False,verify=False): to be in use as of 2011.""" try: assert re.match(VALID_ADDRESS_REGEXP, email) is not None - mx |= verify - if mx: + check_mx |= verify + if check_mx: if not DNS: raise Exception('For check the mx records or check if the email exists you must have installed pyDNS python package') DNS.DiscoverNameServers() hostname = email[email.find('@')+1:]