Skip to content

Commit

Permalink
Changed from mx to check_mx
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Apr 7, 2012
1 parent 8fcf614 commit 86ae68a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
build
dist
MANIFEST
*.egg-info
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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('[email protected]',mx=True)
is_valid = validate_email('[email protected]',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('[email protected]',verify=True)
Expand Down
6 changes: 3 additions & 3 deletions validate_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:]
Expand Down

0 comments on commit 86ae68a

Please sign in to comment.