发送邮件支持 ssl 465端口

pull/17/head
youngS 4 years ago
parent 2980131dd3
commit a320bd9165
  1. 4
      fir_ser/api/utils/sendmsg/emailApi.py
  2. 11
      fir_ser/fir_ser/settings.py

@ -9,12 +9,13 @@ from django.core.mail import send_mail
class EmailMsgSender(object): class EmailMsgSender(object):
def __init__(self, email_host, email_port, use_tls, subject, username, password, form, template_code): def __init__(self, email_host, email_port, use_tls, use_ssl, subject, username, password, form, template_code):
self.email_host = email_host self.email_host = email_host
self.email_port = email_port self.email_port = email_port
self.username = username self.username = username
self.password = password self.password = password
self.use_tls = use_tls self.use_tls = use_tls
self.use_ssl = use_ssl
self.form = form self.form = form
self.subject = subject self.subject = subject
self.template_code = template_code self.template_code = template_code
@ -28,6 +29,7 @@ class EmailMsgSender(object):
settings.EMAIL_HOST_PASSWORD = self.password settings.EMAIL_HOST_PASSWORD = self.password
settings.EMAIL_FROM = self.form settings.EMAIL_FROM = self.form
settings.EMAIL_USE_TLS = self.use_tls settings.EMAIL_USE_TLS = self.use_tls
settings.EMAIL_USE_SSL = self.use_ssl
def send_msg(self, template_code, email, code): def send_msg(self, template_code, email, code):
try: try:

@ -270,12 +270,13 @@ THIRD_PART_CONFIG = {
'name': 'email', 'name': 'email',
'type': 0, 'type': 0,
'auth': { 'auth': {
'email_host': 'smtp.hehegames.cn', 'email_host': 'smtp.126.com',
'email_port': '25', 'email_port': 465,
'use_tls': False, 'use_tls': False,
'username': 'git@hehegames.cn', 'use_ssl': True,
'password': 'QE.54272cd.ecQ.wSj', 'username': 'flyapps@126.com',
'form': 'FlyApp Validation <noreply@hehegames.cn>', 'password': 'GGHFEUMZBRZIFZGQ',
'form': 'FlyApp Validation <flyapps@126.com>',
'subject': '%(code)s验证', 'subject': '%(code)s验证',
'template_code': { 'template_code': {
'login': '验证码%(code)s,您正在登录,若非本人操作,请勿泄露。', 'login': '验证码%(code)s,您正在登录,若非本人操作,请勿泄露。',

Loading…
Cancel
Save