mirror of
https://github.com/aljazceru/validate_email.git
synced 2025-12-20 07:24:21 +01:00
Updated to Python 3.
In order to preserve compatibility with Python 2, raw_input was preserved.
This commit is contained in:
@@ -22,6 +22,12 @@ import smtplib
|
||||
import logging
|
||||
import socket
|
||||
|
||||
try:
|
||||
raw_input
|
||||
except NameError:
|
||||
def raw_input(prompt=''):
|
||||
return input(prompt)
|
||||
|
||||
try:
|
||||
import DNS
|
||||
ServerError = DNS.ServerError
|
||||
@@ -94,7 +100,7 @@ def get_mx_ip(hostname):
|
||||
if hostname not in MX_DNS_CACHE:
|
||||
try:
|
||||
MX_DNS_CACHE[hostname] = DNS.mxlookup(hostname)
|
||||
except ServerError, e:
|
||||
except ServerError as e:
|
||||
if e.rcode == 3: # NXDOMAIN (Non-Existent Domain)
|
||||
MX_DNS_CACHE[hostname] = None
|
||||
else:
|
||||
@@ -191,11 +197,11 @@ if __name__ == "__main__":
|
||||
|
||||
result = validate_email(email, mx, validate, debug=True, smtp_timeout=1)
|
||||
if result:
|
||||
print "Valid!"
|
||||
print("Valid!")
|
||||
elif result is None:
|
||||
print "I'm not sure."
|
||||
print("I'm not sure.")
|
||||
else:
|
||||
print "Invalid!"
|
||||
print("Invalid!")
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user