我尝试获取validate_email包(https://pypi.python.org/pypi/validate_email)以在Windows 7 / Python 2.7设备上验证我的电子邮件。以下作品:
>>> validate_email('example@example.com')
True
>>> validate_email('example@example.com',check_mx=True)
True
>>> validate_email('example@example.com',verify=True)
True
但是,当我尝试使用商业电子邮件服务器示例来检查主机是否有SMPT服务器和/或电子邮件确实存在时,它会失败,如下所示:
>>> validate_email('example@gmail.com')
True
>>> validate_email('example@gmail.com',check_mx=True)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\lib\site-packages\validate_email.py", line 104, in validate_email
smtp.connect(mx[1])
File "C:\Python27\lib\smtplib.py", line 309, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python27\lib\smtplib.py", line 284, in _get_socket
return socket.create_connection((port, host), timeout)
File "C:\Python27\lib\socket.py", line 571, in create_connection
raise err
error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions
>>> validate_email('example@gmail.com',verify=True)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python27\lib\site-packages\validate_email.py", line 104, in validate_email
smtp.connect(mx[1])
File "C:\Python27\lib\smtplib.py", line 309, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python27\lib\smtplib.py", line 284, in _get_socket
return socket.create_connection((port, host), timeout)
File "C:\Python27\lib\socket.py", line 571, in create_connection
raise err
error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions
看来我正在尝试访问我没有权限的端口,但我不知道如何更改为可以正常工作且具有正确权限的端口。
有什么建议吗?