From 830343bf78c54774e884d518aebe52af01ddc105 Mon Sep 17 00:00:00 2001 From: Adam Coddington Date: Mon, 13 Apr 2015 20:13:24 -0700 Subject: [PATCH] Always read file object in as bytes; fixes bug in which non-local file storage caused get_email_object to fail. --- django_mailbox/__init__.py | 2 +- django_mailbox/models.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/django_mailbox/__init__.py b/django_mailbox/__init__.py index a36a695..a748043 100644 --- a/django_mailbox/__init__.py +++ b/django_mailbox/__init__.py @@ -1 +1 @@ -__version__ = '4.3.2' +__version__ = '4.3.3' diff --git a/django_mailbox/models.py b/django_mailbox/models.py index 4f36040..2f0819f 100644 --- a/django_mailbox/models.py +++ b/django_mailbox/models.py @@ -621,8 +621,9 @@ class Message(models.Model): def get_email_object(self): """ Returns an `email.message.Message` instance for this message.""" if self.eml: - return email.message_from_file(self.eml) - body = self.get_body() + body = self.eml.file.read() + else: + body = self.get_body() if six.PY3: flat = email.message_from_bytes(body) else: