Handle socket errors
This commit is contained in:
parent
f457620ea4
commit
0334b368b1
|
@ -1,3 +1,6 @@
|
||||||
|
0.1.5:
|
||||||
|
- Handle socket errors (https://docs.python.org/3/library/socket.html#exceptions)
|
||||||
|
|
||||||
0.1.4:
|
0.1.4:
|
||||||
- Handle 'No MX record' exception
|
- Handle 'No MX record' exception
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -26,7 +26,7 @@ class PostBuildPyCommand(build_py):
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='py3-validate-email',
|
name='py3-validate-email',
|
||||||
version='0.1.4',
|
version='0.1.5',
|
||||||
packages=find_packages(exclude=['tests']),
|
packages=find_packages(exclude=['tests']),
|
||||||
install_requires=['dnspython'],
|
install_requires=['dnspython'],
|
||||||
author='László Károlyi',
|
author='László Károlyi',
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from re import compile as re_compile
|
from re import compile as re_compile
|
||||||
from smtplib import SMTP, SMTPServerDisconnected
|
from smtplib import SMTP, SMTPServerDisconnected
|
||||||
|
from socket import error as SocketError
|
||||||
from socket import gethostname
|
from socket import gethostname
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
@ -49,7 +50,10 @@ def mx_check(
|
||||||
return False
|
return False
|
||||||
|
|
||||||
for mx_record in mx_records:
|
for mx_record in mx_records:
|
||||||
smtp.connect(mx_record)
|
try:
|
||||||
|
smtp.connect(mx_record)
|
||||||
|
except SocketError:
|
||||||
|
continue
|
||||||
smtp.helo(host)
|
smtp.helo(host)
|
||||||
smtp.mail(from_address)
|
smtp.mail(from_address)
|
||||||
code, message = smtp.rcpt(email_address)
|
code, message = smtp.rcpt(email_address)
|
||||||
|
|
Loading…
Reference in New Issue