From 1592c8e7246adfcc951c9a99108140de9503e2cc Mon Sep 17 00:00:00 2001 From: Mathias Rav Date: Fri, 1 May 2015 16:58:56 +0200 Subject: [PATCH] MIMEPart does not exist in Python 2 --- emailtunnel/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/emailtunnel/__init__.py b/emailtunnel/__init__.py index a742b65..8802472 100644 --- a/emailtunnel/__init__.py +++ b/emailtunnel/__init__.py @@ -187,7 +187,10 @@ def set_unique_header(self, key, value): self.message[key] = value def set_body_text(self, body, encoding): - body_part = email.message.MIMEPart() + if six.PY3: + body_part = email.message.MIMEPart() + else: + body_part = email.message.Message() if encoding: encoded = body.encode(encoding) body_part.set_payload(encoded)