Skip to content

Commit

Permalink
Ignore SMTPServerDisconnected from smtp.quit()
Browse files Browse the repository at this point in the history
This exception is raised by smtp.quit() for some smtp servers (for example
laposte.net).
  • Loading branch information
cdevienne committed Apr 8, 2014
1 parent b7c5861 commit 25d16d8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion validate_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ def validate_email(email, check_mx=False, verify=False, debug=False, smtp_timeou
smtp = smtplib.SMTP(timeout=smtp_timeout)
smtp.connect(mx[1])
if not verify:
smtp.quit()
try:
smtp.quit()
except smtplib.SMTPServerDisconnected:
pass
return True
status, _ = smtp.helo()
if status != 250:
Expand Down

0 comments on commit 25d16d8

Please sign in to comment.