mirror of
https://github.com/django/django.git
synced 2025-03-12 18:30:48 +00:00
[1.6.x] Decode mails using the message encoding.
Backport of bfe9052831c6d7ad7501b71c884525b3b471eebc from master.
This commit is contained in:
parent
d18f99dfc7
commit
e99eeefe44
@ -14,10 +14,12 @@ class EmailBackend(BaseEmailBackend):
|
||||
super(EmailBackend, self).__init__(*args, **kwargs)
|
||||
|
||||
def write_message(self, message):
|
||||
msg = message.message().as_bytes()
|
||||
msg = message.message()
|
||||
msg_data = msg.as_bytes()
|
||||
if six.PY3:
|
||||
msg = msg.decode()
|
||||
self.stream.write('%s\n' % msg)
|
||||
charset = msg.get_charset().get_output_charset() if msg.get_charset() else 'utf-8'
|
||||
msg_data = msg_data.decode(charset)
|
||||
self.stream.write('%s\n' % msg_data)
|
||||
self.stream.write('-' * 79)
|
||||
self.stream.write('\n')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user