Permalink
Browse files

[1.6.x] Decode mails using the message encoding.

Backport of bfe9052 from master.
  • Loading branch information...
1 parent d18f99d commit e99eeefe4403668561048753dd8def5cfee3b5aa @apollo13 apollo13 committed Dec 30, 2013
Showing with 5 additions and 3 deletions.
  1. +5 −3 django/core/mail/backends/console.py
@@ -14,10 +14,12 @@ def __init__(self, *args, **kwargs):
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')

0 comments on commit e99eeef

Please sign in to comment.