mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
Decode mails using the message encoding.
This commit is contained in:
@@ -15,10 +15,12 @@ class EmailBackend(BaseEmailBackend):
|
|||||||
super(EmailBackend, self).__init__(*args, **kwargs)
|
super(EmailBackend, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def write_message(self, message):
|
def write_message(self, message):
|
||||||
msg = message.message().as_bytes()
|
msg = message.message()
|
||||||
|
msg_data = msg.as_bytes()
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
msg = msg.decode()
|
charset = msg.get_charset().get_output_charset() if msg.get_charset() else 'utf-8'
|
||||||
self.stream.write('%s\n' % msg)
|
msg_data = msg_data.decode(charset)
|
||||||
|
self.stream.write('%s\n' % msg_data)
|
||||||
self.stream.write('-' * 79)
|
self.stream.write('-' * 79)
|
||||||
self.stream.write('\n')
|
self.stream.write('\n')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user