import dns.resolver
import socket
import smtplib
import socks
我在这里添加代理:
PROXY = '196.89.10.16'
PROXY_PORT = 8080
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4, PROXY, PROXY_PORT , True)
socks.wrapmodule(smtplib)
我正在获取dns mxrecord:
records = dns.resolver.query('gmail.com', 'MX')
mxRecord = records[0].exchange
mxRecord = str(mxRecord)
print mxRecord
server = smtplib.SMTP()
server.set_debuglevel(0)
连接到mxRecord:
server.connect(mxRecord)
server.helo('hello')
print server.helo_resp
server.mail('example@example.org')
addressToVerify = 'example@gmail.com'
我正在验证帐号是否存在:
code, message = server.rcpt(str(addressToVerify))
print code
print message
#returns 250 on success
# Assume 250 as Success
if code == 250:
print('Success')
else:
print('Bad')
我想添加代理来调用rcpt
函数。
请帮忙。