use proper email header encoding

This commit is contained in:
Martin Zimmermann 2013-10-13 15:52:50 +02:00
parent e8d62e5db1
commit 5d0cad4272

View File

@ -1,6 +1,7 @@
# -*- encoding: utf-8 -*-
from smtplib import SMTP, SMTP_SSL
from email.header import Header
from email.mime.text import MIMEText
@ -60,7 +61,7 @@ class SMTPMailer(object):
msg = MIMEText(body, 'plain', 'utf-8')
msg['From'] = "Ich schrei sonst! <%s>" % self.from_addr
msg['To'] = self.to_addr
msg['Subject'] = subject.encode('utf-8')
msg['Subject'] = Header(subject, 'utf-8')
with Connection(self.conf) as con:
con.sendmail(self.from_addr, self.to_addr, msg.as_string())