From 550ca8941565ed0625de94d6f8247d10964aaa32 Mon Sep 17 00:00:00 2001 From: Pawel M Date: Thu, 8 Dec 2016 15:14:11 +0100 Subject: [PATCH] PY3 get_email support in method ticket_from_message (if message isinstance bytes use email.email_from_bytes(msg) else ..from_string(msg)) --- helpdesk/management/commands/get_email.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index b1809afa..d9a1969f 100644 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -268,7 +268,13 @@ def ticket_from_message(message, queue, logger): if six.PY2: message = email.message_from_string(msg) elif six.PY3: - message = email.message_from_bytes(msg) + print(type(msg)) + print(msg) + print(isinstance(msg, bytes)) + if isinstance(msg, bytes): + message = email.message_from_bytes(msg) + else: + message = email.message_from_string(msg) subject = message.get('subject', _('Created from e-mail')) subject = decode_mail_headers(decodeUnknown(message.get_charset(), subject)) for affix in STRIPPED_SUBJECT_STRINGS: