Skip to content

Commit

Permalink
Merge pull request syrusakbary#3 from decibyte/master
Browse files Browse the repository at this point in the history
Now quitting SMTP connection
  • Loading branch information
syrusakbary committed May 3, 2013
2 parents 92c6a31 + 7021c42 commit e843df2
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 e843df2

Please sign in to comment.