Merge pull request #964 from matclab/mail-send-lazy-to-unicode

#963 : Convert subject and body to unicode before sending mail
This commit is contained in:
mdipierro
2015-05-14 09:17:04 -05:00
+7 -7
View File
@@ -767,8 +767,8 @@ class Mail(object):
if self.settings.server == 'logging': if self.settings.server == 'logging':
logger.warn('email not sent\n%s\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n%s\n' % logger.warn('email not sent\n%s\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n%s\n' %
('-' * 40, sender, ('-' * 40, sender,
', '.join(to), subject, ', '.join(to), subject,
text or html, '-' * 40)) text or html, '-' * 40))
elif self.settings.server == 'gae': elif self.settings.server == 'gae':
xcc = dict() xcc = dict()
if cc: if cc:
@@ -779,23 +779,23 @@ class Mail(object):
xcc['reply_to'] = reply_to xcc['reply_to'] = reply_to
from google.appengine.api import mail from google.appengine.api import mail
attachments = attachments and [mail.Attachment( attachments = attachments and [mail.Attachment(
a.my_filename, a.my_filename,
a.my_payload, a.my_payload,
contebt_id='<attachment-%s>' % k contebt_id='<attachment-%s>' % k
) for k,a in enumerate(attachments) if not raw] ) for k,a in enumerate(attachments) if not raw]
if attachments: if attachments:
result = mail.send_mail( result = mail.send_mail(
sender=sender, to=origTo, sender=sender, to=origTo,
subject=subject, body=text, html=html, subject=unicode(subject), body=unicode(text), html=html,
attachments=attachments, **xcc) attachments=attachments, **xcc)
elif html and (not raw): elif html and (not raw):
result = mail.send_mail( result = mail.send_mail(
sender=sender, to=origTo, sender=sender, to=origTo,
subject=subject, body=text, html=html, **xcc) subject=unicode(subject), body=unicode(text), html=html, **xcc)
else: else:
result = mail.send_mail( result = mail.send_mail(
sender=sender, to=origTo, sender=sender, to=origTo,
subject=subject, body=text, **xcc) subject=unicode(subject), body=unicode(text), **xcc)
else: else:
smtp_args = self.settings.server.split(':') smtp_args = self.settings.server.split(':')
kwargs = dict(timeout=self.settings.timeout) kwargs = dict(timeout=self.settings.timeout)
@@ -3714,7 +3714,7 @@ class Auth(object):
return record.id return record.id
else: else:
id = membership.insert(group_id=group_id, user_id=user_id) id = membership.insert(group_id=group_id, user_id=user_id)
if role: if role:
self.user_groups[group_id] = role self.user_groups[group_id] = role
else: else:
self.update_groups() self.update_groups()