Commit 2f66a8c1 authored by shenshuo's avatar shenshuo

tls 发送邮件增加端口

parent 257acbc4
......@@ -18,7 +18,7 @@ import uuid
class SendMail(object):
def __init__(self, mail_host, mail_port, mail_user, mail_password, mail_ssl, mail_tls=False):
def __init__(self, mail_host, mail_port, mail_user, mail_password, mail_ssl):
"""
:param mail_host: SMTP主机
:param mail_port: SMTP端口
......@@ -31,7 +31,6 @@ class SendMail(object):
self.__mail_user = mail_user
self.__mail_password = mail_password
self.mail_ssl = mail_ssl
self.mail_tls = mail_tls
def send_mail(self, to_list, subject, content, subtype='plain', att=None):
"""
......@@ -68,20 +67,11 @@ class SendMail(object):
server.login(self.__mail_user, self.__mail_password) # 登录操作
server.sendmail(self.__mail_user, to_list.split(','), msg.as_string())
server.close()
# elif self.mail_tls:
# # print('Use TLS SendMail')
# '''使用TLS模式'''
# server = smtplib.SMTP()
# server.connect(self.mail_host, self.mail_port) # 连接服务器
# server.starttls()
# server.login(self.__mail_user, self.__mail_password) # 登录操作
# server.sendmail(self.__mail_user, to_list.split(','), msg.as_string())
# server.close()
# return True
else:
'''使用普通模式'''
server = smtplib.SMTP()
server.connect(self.mail_host, self.mail_port) # 连接服务器
# server.starttls()
server.login(self.__mail_user, self.__mail_password) # 登录操作
server.sendmail(self.__mail_user, to_list.split(','), msg.as_string())
server.close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment