1
0
Fork 0
django-mailbox/django_mailbox/transports/base.py

27 lines
754 B
Python
Raw Permalink Normal View History

import email
import six
# Do *not* remove this, we need to use this in subclasses of EmailTransport
if six.PY3:
2017-05-09 23:59:42 +02:00
from email.errors import MessageParseError # noqa: F401
else:
2017-05-09 23:59:42 +02:00
from email.Errors import MessageParseError # noqa: F401
class EmailTransport(object):
def get_email_from_bytes(self, contents):
if six.PY3:
message = email.message_from_bytes(contents)
else:
message = email.message_from_string(contents)
return message
2018-05-15 00:52:46 +02:00
class PluggableEmailTransport(EmailTransport):
@classmethod
def from_uri(cls, uri):
raise NotImplemented("The class does not implement {0}.from_uri, and it should. "
"Overwrite {0}.from_uri.".format(cls.__name__))