mirror of
https://github.com/aljazceru/validate_email.git
synced 2025-12-19 15:14:18 +01:00
Merge pull request #3 from decibyte/master
Now quitting SMTP connection
This commit is contained in:
@@ -102,12 +102,19 @@ def validate_email(email, check_mx=False,verify=False):
|
|||||||
try:
|
try:
|
||||||
smtp = smtplib.SMTP()
|
smtp = smtplib.SMTP()
|
||||||
smtp.connect(mx[1])
|
smtp.connect(mx[1])
|
||||||
if not verify: return True
|
if not verify:
|
||||||
|
smtp.quit()
|
||||||
|
return True
|
||||||
status, _ = smtp.helo()
|
status, _ = smtp.helo()
|
||||||
if status != 250: continue
|
if status != 250:
|
||||||
|
smtp.quit()
|
||||||
|
continue
|
||||||
smtp.mail('')
|
smtp.mail('')
|
||||||
status, _ = smtp.rcpt(email)
|
status, _ = smtp.rcpt(email)
|
||||||
if status != 250: return False
|
if status != 250:
|
||||||
|
smtp.quit()
|
||||||
|
return False
|
||||||
|
smtp.quit()
|
||||||
break
|
break
|
||||||
except smtplib.SMTPServerDisconnected: #Server not permits verify user
|
except smtplib.SMTPServerDisconnected: #Server not permits verify user
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user