diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index f5b57e76..d57189c4 100755 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -25,6 +25,8 @@ import base64 import binascii from time import ctime +from bs4 import BeautifulSoup + from email_reply_parser import EmailReplyParser from django.core.files.base import ContentFile @@ -366,7 +368,12 @@ def ticket_from_message(message, queue, logger): counter += 1 if not body: - body = _('No plain-text email body available. Please see attachment "email_html_body.html".') + mail = BeautifulSoup(part.get_payload(), "lxml") + if ">" in mail.text: + message_body = mail.text.split(">")[1] + body = message_body.encode('ascii', errors='ignore') + else: + body = mail.text if ticket: try: diff --git a/requirements.txt b/requirements.txt index 5e34629e..a5b92c29 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,8 @@ Django>=1.11,<2 django-bootstrap-form>=3.3,<4 email-reply-parser django-markdown-deux +beautifulsoup4 +lxml simplejson pytz six