From c04b9fd7f6a63c2889c59e0168956d89369c4876 Mon Sep 17 00:00:00 2001 From: phail Date: Thu, 19 May 2022 22:51:17 +0200 Subject: [PATCH] switch to From: Header instead of date to compensate for older libmagic versions --- src/paperless_mail/mail.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py index c834701b4..d52d86025 100644 --- a/src/paperless_mail/mail.py +++ b/src/paperless_mail/mail.py @@ -342,7 +342,7 @@ class MailAccountHandler(LoggingMixin): suffix=".eml", ) with open(temp_filename, "wb") as f: - # Move "Date"-header to beginning of file + # Move "From"-header to beginning of file # TODO: This ugly workaround is needed because the parser is # chosen only by the mime_type detected via magic # (see documents/consumer.py "mime_type = magic.from_file") @@ -351,12 +351,12 @@ class MailAccountHandler(LoggingMixin): # detects text/plain. # This also effects direct file consumption of .eml files # which are not treated with this workaround. - date_element = None + from_element = None for i, header in enumerate(message.obj._headers): - if header[0] == "Date": - date_element = i - if date_element: - new_headers = [message.obj._headers.pop(date_element)] + if header[0] == "From": + from_element = i + if from_element: + new_headers = [message.obj._headers.pop(from_element)] new_headers += message.obj._headers message.obj._headers = new_headers