From 72e906fbd4894d6b4e7d94d051689d6d2c89d007 Mon Sep 17 00:00:00 2001 From: gnusec Date: Fri, 4 May 2018 01:18:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=82=AE=E4=BB=B6=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98,=E5=92=8C?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E9=82=AE=E4=BB=B6=E6=A0=87=E9=A2=98=E4=B9=B1?= =?UTF-8?q?=E7=A0=81=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cobra/send_mail.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cobra/send_mail.py b/cobra/send_mail.py index a3bd3eb9..bcb5bac8 100644 --- a/cobra/send_mail.py +++ b/cobra/send_mail.py @@ -4,6 +4,7 @@ from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText +from email.header import Header from .config import Config from .log import logger @@ -12,12 +13,11 @@ def send_mail(target, filename, receiver): host = Config('email', 'host').value - port = Config('email', 'port').value + port = int(Config('email', 'port').value) username = Config('email', 'username').value password = Config('email', 'password').value sender = Config('email', 'sender').value is_ssl = to_bool(Config('email', 'ssl').value) - if is_ssl: server = smtplib.SMTP_SSL(host=host, port=port) else: @@ -27,7 +27,7 @@ def send_mail(target, filename, receiver): msg = MIMEMultipart() msg['From'] = sender msg['To'] = receiver - msg['Subject'] = '编号 {sid} 项目 Cobra 扫描报告'.format(sid=s_sid) + msg['Subject'] = Header('编号 {sid} 项目 Cobra 扫描报告'.format(sid=s_sid), 'utf-8').encode() msg.attach(MIMEText('扫描项目:{t}\n报告见附件'.format(t=target), 'plain', 'utf-8'))