fixed subject decoding

slight_refactoring
Sascha Rommelfangen 2018-04-13 10:27:14 +02:00 committed by GitHub
parent a6605cdec4
commit aaab73cdf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -94,7 +94,13 @@ msg = email.message_from_string(mailcontent)
if not mail_subject:
try:
mail_subject = msg.get('Subject').encode("utf-8", "ignore")
except:
sub, enc = email.header.decode_header(msg.get('subject'))[0]
if enc==None:
email_subject = sub
else:
email_subject = sub.decode(enc)
except Exception as e:
print(e)
pass
for part in msg.walk():
if part.get_content_charset() is None: