Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Decode mails using the message encoding.

  • Loading branch information...
commit bfe9052831c6d7ad7501b71c884525b3b471eebc 1 parent c988745
@apollo13 apollo13 authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 django/core/mail/backends/console.py
View
8 django/core/mail/backends/console.py
@@ -15,10 +15,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')
Please sign in to comment.
Something went wrong with that request. Please try again.