forked from extern/django-helpdesk
Use BeautifulSoup to get text out of HTML-only emails, to address issue in #565
This commit is contained in:
parent
8f375e1379
commit
65c1d05eef
@ -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:
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user