Skip to content

Commit

Permalink
handle timeout exception in smpt connection (socket.error)
Browse files Browse the repository at this point in the history
  • Loading branch information
joke2k committed Apr 5, 2013
1 parent 8c837b4 commit 2266da4
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 @@ -111,7 +111,10 @@ def validate_email(email, check_mx=False,verify=False):
for mx in mx_hosts:
try:
smtp = smtplib.SMTP()
smtp.connect(mx.exchange.to_text())
try:
smtp.connect(mx.exchange.to_text())
except socket.error:
continue
if not verify: return True
status, _ = smtp.helo()
if status != 250: continue
Expand Down

0 comments on commit 2266da4

Please sign in to comment.