def __init__(self):
# get info from the config
sc = SC()
self.me = sc.smtp_from
self.username = sc.smtp_username
self.password = sc.smtp_password
self.server_name = sc.smtp_server
self.server_port = sc.smtp_port
self.log = ''
if sc.use_proxy is True:
# try to wrap the smtplib library with the socks module
if sc.proxy_username and sc.proxy_password:
try:
socks.set_default_proxy('socks.PROXY_TYPE_SOCKS4',
sc.proxy_server,
sc.proxy_port,
username=sc.proxy_username,
password=sc.proxy_password)
socks.wrap_module(smtplib)
except:
try:
socks.set_default_proxy('socks.PROXY_TYPE_SOCKS5',
sc.proxy_server,
sc.proxy_port,
username=sc.proxy_username,
password=sc.proxy_password)
socks.wrap_module(smtplib)
except:
try:
socks.set_default_proxy('socks.PROXY_TYPE_SOCKS4',
sc.proxy_server,
sc.proxy_port)
socks.wrap_module(smtplib)
except:
try:
socks.set_default_proxy('socks.PROXY_TYPE_SOCKS5',
sc.proxy_server,
sc.proxy_port)
socks.wrap_module(smtplib)
except:
self.log += 'Unable to access SMTP through proxy'
else:
try:
socks.set_default_proxy('socks.PROXY_TYPE_SOCKS4',
sc.proxy_server,
sc.proxy_port)
socks.wrap_module(smtplib)
except:
try:
socks.set_default_proxy('socks.PROXY_TYPE_SOCKS5',
sc.proxy_server,
sc.proxy_port)
socks.wrap_module(smtplib)
except:
self.log += 'Unable to access SMTP through proxy'
评论列表
文章目录