diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index 0bf4c0a3..b1809afa 100644 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -205,9 +205,9 @@ def process_queue(q, logger): ticket = ticket_from_message(message=encoding.smart_text(data[0][1]), queue=q, logger=logger) if ticket: server.store(num, '+FLAGS', '\\Deleted') - logger.info("Successfully processed message %s, deleted from IMAP server" % num) + logger.info("Successfully processed message %s, deleted from IMAP server" % str(num)) else: - logger.warn("Message %s was not successfully processed, and will be left on IMAP server" % num) + logger.warn("Message %s was not successfully processed, and will be left on IMAP server" % str(num)) server.expunge() server.close() @@ -264,7 +264,11 @@ def decode_mail_headers(string): def ticket_from_message(message, queue, logger): # 'message' must be an RFC822 formatted message. - message = email.message_from_string(message) + msg = message + if six.PY2: + message = email.message_from_string(msg) + elif six.PY3: + message = email.message_from_bytes(msg) subject = message.get('subject', _('Created from e-mail')) subject = decode_mail_headers(decodeUnknown(message.get_charset(), subject)) for affix in STRIPPED_SUBJECT_STRINGS: