Fixed error with sending emails if recipient name contains non ascii
chars.
This commit is contained in:
@@ -32,7 +32,7 @@ def get_recipients(task, sport=None):
|
|||||||
else:
|
else:
|
||||||
raise ValueError('utils.get_recipients(): invalid value for task')
|
raise ValueError('utils.get_recipients(): invalid value for task')
|
||||||
|
|
||||||
return ['{name} <{addr}>'.format(name=u.get_full_name(), addr=u.email) for u in users]
|
return [u'{name} <{addr}>'.format(name=u.get_full_name(), addr=u.email) for u in users]
|
||||||
|
|
||||||
|
|
||||||
class AbstractMail(object):
|
class AbstractMail(object):
|
||||||
@@ -73,7 +73,7 @@ class AbstractMail(object):
|
|||||||
recipients = self._get_recipients()
|
recipients = self._get_recipients()
|
||||||
|
|
||||||
emo = EmailMessage(subject=subject, body=body, from_email=sender, to=recipients)
|
emo = EmailMessage(subject=subject, body=body, from_email=sender, to=recipients)
|
||||||
logger.info('Send %s to %s', self.__class__.__name__, recipients)
|
logger.info(u'Send %s to %s', self.__class__.__name__, recipients)
|
||||||
emo.send()
|
emo.send()
|
||||||
|
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ class NewEventMail(AbstractEventMail):
|
|||||||
return s
|
return s
|
||||||
|
|
||||||
def _get_recipients(self):
|
def _get_recipients(self):
|
||||||
r = '{fullname} <{email}>'.format(fullname=self._event.owner.get_full_name(),
|
r = u'{fullname} <{email}>'.format(fullname=self._event.owner.get_full_name(),
|
||||||
email=self._event.owner.email)
|
email=self._event.owner.email)
|
||||||
return [r]
|
return [r]
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ class EventAcceptedMail(AbstractEventMail):
|
|||||||
return s
|
return s
|
||||||
|
|
||||||
def _get_recipients(self):
|
def _get_recipients(self):
|
||||||
r = '{fullname} <{email}>'.format(fullname=self._event.owner.get_full_name(),
|
r = u'{fullname} <{email}>'.format(fullname=self._event.owner.get_full_name(),
|
||||||
email=self._event.owner.email)
|
email=self._event.owner.email)
|
||||||
return [r]
|
return [r]
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ class PasswordSetEmail(AbstractMail):
|
|||||||
self._password = password
|
self._password = password
|
||||||
|
|
||||||
def _get_recipients(self):
|
def _get_recipients(self):
|
||||||
r = '{fullname} <{email}>'.format(fullname=self._user.get_full_name(),
|
r = u'{fullname} <{email}>'.format(fullname=self._user.get_full_name(),
|
||||||
email=self._user.email)
|
email=self._user.email)
|
||||||
return [r]
|
return [r]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user