Skip to content

Commit

Permalink
Merge pull request #964 from matclab/mail-send-lazy-to-unicode
Browse files Browse the repository at this point in the history
#963 : Convert subject and body to unicode before sending mail
  • Loading branch information
mdipierro committed May 14, 2015
2 parents f77f307 + a6226d6 commit 76cfba7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions gluon/tools.py
Expand Up @@ -767,8 +767,8 @@ def encoded_or_raw(text):
if self.settings.server == 'logging':
logger.warn('email not sent\n%s\nFrom: %s\nTo: %s\nSubject: %s\n\n%s\n%s\n' %
('-' * 40, sender,
', '.join(to), subject,
text or html, '-' * 40))
', '.join(to), subject,
text or html, '-' * 40))
elif self.settings.server == 'gae':
xcc = dict()
if cc:
Expand All @@ -779,23 +779,23 @@ def encoded_or_raw(text):
xcc['reply_to'] = reply_to
from google.appengine.api import mail
attachments = attachments and [mail.Attachment(
a.my_filename,
a.my_filename,
a.my_payload,
contebt_id='<attachment-%s>' % k
) for k,a in enumerate(attachments) if not raw]
if attachments:
result = mail.send_mail(
sender=sender, to=origTo,
subject=subject, body=text, html=html,
subject=unicode(subject), body=unicode(text), html=html,
attachments=attachments, **xcc)
elif html and (not raw):
result = mail.send_mail(
sender=sender, to=origTo,
subject=subject, body=text, html=html, **xcc)
subject=unicode(subject), body=unicode(text), html=html, **xcc)
else:
result = mail.send_mail(
sender=sender, to=origTo,
subject=subject, body=text, **xcc)
subject=unicode(subject), body=unicode(text), **xcc)
else:
smtp_args = self.settings.server.split(':')
kwargs = dict(timeout=self.settings.timeout)
Expand Down Expand Up @@ -3714,7 +3714,7 @@ def add_membership(self, group_id=None, user_id=None, role=None):
return record.id
else:
id = membership.insert(group_id=group_id, user_id=user_id)
if role:
if role:
self.user_groups[group_id] = role
else:
self.update_groups()
Expand Down

0 comments on commit 76cfba7

Please sign in to comment.