我正在使用此代码验证电子邮件。它在前几次验证时运行,但很快就显示出错误OSError:[Errno 101]当我经常运行它时,网络无法访问。请帮忙!感谢
def validate_email(email):
import dns.resolver
import socket
import smtplib
splitAddress = email.split('@')
domain = str(splitAddress[1])
records = dns.resolver.query(domain, 'MX')
mxRecord = records[0].exchange
mxRecord = str(mxRecord)
host = socket.gethostname()
server = smtplib.SMTP()
server.set_debuglevel(0)
server.connect(mxRecord)
server.helo(host)
server.mail('me@domain.com')
code, message = server.rcpt(str(email))
server.quit()
time.sleep(1)
return code