Changed from mx to check_mx
This commit is contained in:
parent
8fcf614de6
commit
86ae68a53c
3 changed files with 6 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@
|
|||
build
|
||||
dist
|
||||
MANIFEST
|
||||
*.egg-info
|
|
@ -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)
|
||||
|
|
|
@ -81,7 +81,7 @@ ADDR_SPEC = LOCAL_PART + r'@' + DOMAIN # see 3.4.1
|
|||
# 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:]
|
||||
|
|
Loading…
Reference in a new issue