Changed console and filebackend to use msg.as_bytes to output the data as it would get send via smtp.

This commit is contained in:
Florian Apolloner 2013-12-30 23:45:43 +01:00
parent 5dfd824d38
commit c988745cca
3 changed files with 33 additions and 24 deletions

View file

@ -38,6 +38,11 @@ class EmailBackend(ConsoleEmailBackend):
kwargs['stream'] = None
super(EmailBackend, self).__init__(*args, **kwargs)
def write_message(self, message):
self.stream.write(message.message().as_bytes() + b'\n')
self.stream.write(b'-' * 79)
self.stream.write(b'\n')
def _get_filename(self):
"""Return a unique file name."""
if self._fname is None:
@ -48,7 +53,7 @@ class EmailBackend(ConsoleEmailBackend):
def open(self):
if self.stream is None:
self.stream = open(self._get_filename(), 'a')
self.stream = open(self._get_filename(), 'ab')
return True
return False