Ignore SMTPServerDisconnected from smtp.quit()

This exception is raised by smtp.quit() for some smtp servers (for example
laposte.net).
This commit is contained in:
Christophe de Vienne
2014-04-08 11:47:42 +02:00
parent b7c5861588
commit 25d16d8a4d

View File

@@ -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: