Permalink
Browse files

return false if not_found cannot be confirmed

  • Loading branch information...
1 parent a876cbd commit 04fbc501ae74c1065d47a6624a99325314148f66 Val Neekman committed Oct 15, 2012
Showing with 14 additions and 6 deletions.
  1. +14 −6 emailahoy/__init__.py
View
@@ -48,7 +48,8 @@ def get_mx_for_hostname(self, hostname):
except:
pass
return mx
-
+
+
# given a host name, returns True if valid, else False
def is_hostname_valid(self, hostname):
""" if hostname is valid """
@@ -58,11 +59,13 @@ def is_hostname_valid(self, hostname):
return False
return True
+
# given an email address, returns True if email matches a valid pattern
def is_email_valid(self, email):
""" if a given email maches the email pattern """
return self.EMAIL_RE.search(email)
+
# given an email, hostname is returned
def get_hostname_from_email(self, email):
try:
@@ -71,6 +74,7 @@ def get_hostname_from_email(self, email):
hostname = None
return hostname
+
# given a hostname, a smtp server connection is returned or None
def get_smtp_connection(self, hostname):
""" returns a server with valid connection if possible """
@@ -85,12 +89,14 @@ def get_smtp_connection(self, hostname):
if connection_success(resp):
return server
return None
-
+
+
# given a response tuple, it returns True if status was success
def was_found(self, resp):
""" email WAS found """
return resp[0] == 250
+
# given a response tuple, it returns True if it can tell if email was not found
def not_found(self, resp):
""" email was NOT found """
@@ -105,14 +111,15 @@ def not_found(self, resp):
"invalid",
"doesn't handle",
]
- if resp[0] != 250 and any(a in resp[1].lower() for a in not_found_words):
- return True
+ return resp[0] != 250 and any(a in resp[1].lower() for a in not_found_words):
+
# given a response tuple, it returns true if it couldn't tell, if email found or not
def could_not_verify_status(self, resp):
""" email unverifiable """
return not (self.was_found(resp) or self.not_found(resp))
-
+
+
# returns a response tuple indicating the existance of an email address
def verify_email_smtp(
self,
@@ -151,7 +158,8 @@ def verify_email_smtp(
if not server:
return (550, 'No-Server-Connection')
return resp
-
+
+
# given an email it returns True if it can tell it exist or False
def verify_email_address(
email,

0 comments on commit 04fbc50

Please sign in to comment.