Skip to content

Commit

Permalink
Merge pull request syrusakbary#29 from berislavlopac/upgrade_python_3
Browse files Browse the repository at this point in the history
Updated to Python 3.
  • Loading branch information
syrusakbary committed Oct 13, 2014
2 parents e5f8797 + 1777ca0 commit 17b7b84
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions validate_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
import logging
import socket

try:
raw_input
except NameError:
def raw_input(prompt=''):
return input(prompt)

try:
import DNS
ServerError = DNS.ServerError
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -191,11 +197,11 @@ def validate_email(email, check_mx=False, verify=False, debug=False, smtp_timeou

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)

Expand Down

0 comments on commit 17b7b84

Please sign in to comment.