From bfe9052831c6d7ad7501b71c884525b3b471eebc Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Mon, 30 Dec 2013 23:54:12 +0100 Subject: [PATCH] Decode mails using the message encoding. --- django/core/mail/backends/console.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/django/core/mail/backends/console.py b/django/core/mail/backends/console.py index 57fa32952d..0ce88534ea 100644 --- a/django/core/mail/backends/console.py +++ b/django/core/mail/backends/console.py @@ -15,10 +15,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')