Skip to content

Commit

Permalink
Quitting SMTP connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikkel Munch Mortensen committed May 2, 2013
1 parent 92c6a31 commit 7021c42
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions validate_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,19 @@ def validate_email(email, check_mx=False,verify=False):
try:
smtp = smtplib.SMTP()
smtp.connect(mx[1])
if not verify: return True
if not verify:
smtp.quit()
return True
status, _ = smtp.helo()
if status != 250: continue
if status != 250:
smtp.quit()
continue
smtp.mail('')
status, _ = smtp.rcpt(email)
if status != 250: return False
if status != 250:
smtp.quit()
return False
smtp.quit()
break
except smtplib.SMTPServerDisconnected: #Server not permits verify user
break
Expand Down

0 comments on commit 7021c42

Please sign in to comment.