markup email handle encoded headers
This commit is contained in:
@ -11,6 +11,7 @@ from pathlib import Path
|
||||
|
||||
from email.feedparser import FeedParser
|
||||
from email.message import EmailMessage
|
||||
from email.header import decode_header, make_header
|
||||
|
||||
import django
|
||||
from django.conf import settings
|
||||
@ -33,15 +34,18 @@ def process_message(path):
|
||||
parser.feed(line)
|
||||
msg = parser.close()
|
||||
|
||||
frm = str(make_header(decode_header(msg['From'])))
|
||||
subject = str(make_header(decode_header(msg['Subject'])))
|
||||
|
||||
found_pdf = False
|
||||
if msg.is_multipart():
|
||||
for attach in msg.walk():
|
||||
if attach.get_content_type() == 'application/pdf':
|
||||
process_attachment(msg['From'], msg['Subject'], attach)
|
||||
found_pdf = True
|
||||
process_attachment(frm, subject, attach)
|
||||
|
||||
if not found_pdf:
|
||||
reply_missing(msg['From'], msg['Subject'])
|
||||
reply_missing(frm, subject)
|
||||
|
||||
|
||||
def process_attachment(from_address, subject, attachment):
|
||||
|
||||
Reference in New Issue
Block a user