fix send email feature: encode subject and message correctly

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3710 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2010-02-02 10:08:45 +00:00
parent 0d8be13807
commit d70b5e5d44
2 changed files with 3 additions and 4 deletions

View file

@ -1,5 +1,5 @@
# #
# Copyright (c) 2007 Helmut Merz helmutm@cy55.de # Copyright (c) 2010 Helmut Merz helmutm@cy55.de
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -123,7 +123,6 @@ def decodeHeader(h):
result.append(v) result.append(v)
return ''.join(result) return ''.join(result)
def getPayload(msg): def getPayload(msg):
parts = {} parts = {}
for msg in msg.walk(): for msg in msg.walk():

View file

@ -156,8 +156,8 @@ class SendEmail(FormController):
recipients += (form.get('addrRecipients') or u'').split('\n') recipients += (form.get('addrRecipients') or u'').split('\n')
person = getPersonForUser(self.context, self.request) person = getPersonForUser(self.context, self.request)
sender = person and adapted(person).email or 'loops@unknown.com' sender = person and adapted(person).email or 'loops@unknown.com'
msg = MIMEText(message, 'plain', 'utf-8') msg = MIMEText(message.encode('utf-8'), 'plain', 'utf-8')
msg['Subject'] = subject msg['Subject'] = subject.encode('utf-8')
msg['From'] = sender msg['From'] = sender
msg['To'] = ', '.join(r.strip() for r in recipients if r.strip()) msg['To'] = ', '.join(r.strip() for r in recipients if r.strip())
mailhost = component.getUtility(IMailDelivery, 'Mail') mailhost = component.getUtility(IMailDelivery, 'Mail')