Don't crash when mail body is empty

This commit is contained in:
Timothy Hobbs 2018-12-19 17:12:46 +01:00
parent c3746ce7b0
commit e66c42890c
No known key found for this signature in database
GPG Key ID: 9CA9B3D779CEEDE7

View File

@ -362,11 +362,13 @@ def ticket_from_message(message, queue, logger):
if not body:
mail = BeautifulSoup(part.get_payload(), "lxml")
if ">" in mail.text:
body = mail.find('body')
body = body.text
body = body.encode('ascii', errors='ignore')
else:
beautiful_body = mail.find('body')
if beautiful_body:
try:
body = beautiful_body.text
except AttributeError:
pass
if not body:
body = mail.text
if ticket: