Repository: paperless-ngx/paperless-ngx

Issue:
[BUG] Document_thumbnails fails on .eml file
### Description

When running the command `docker compose exec webserver document_thumbnails` the following issue is raised

### Steps to reproduce

Run `docker compose exec webserver document_thumbnails` with some emails archived

### Webserver logs

```bash
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/usr/src/paperless/src/documents/management/commands/document_thumbnails.py", line 24, in _process_document
    thumb = parser.get_thumbnail(
  File "/usr/src/paperless/src/paperless_mail/parsers.py", line 36, in get_thumbnail
    self.archive_path = self.generate_pdf(document_path)
  File "/usr/src/paperless/src/paperless_mail/parsers.py", line 192, in generate_pdf
    mail_pdf_file = self.generate_pdf_from_mail(mail_message)
  File "/usr/src/paperless/src/paperless_mail/parsers.py", line 301, in generate_pdf_from_mail
    email_html_file = self.mail_to_html(mail)
  File "/usr/src/paperless/src/paperless_mail/parsers.py", line 259, in mail_to_html
    data["subject"] = clean_html(mail.subject)
AttributeError: 'PosixPath' object has no attribute 'subject'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/paperless/src/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "/usr/src/paperless/src/documents/management/commands/document_thumbnails.py", line 76, in handle
    list(
  File "/usr/local/lib/python3.9/site-packages/tqdm/std.py", line 1178, in __iter__
    for obj in iterable:
  File "/usr/local/lib/python3.9/multiprocessing/pool.py", line 870, in next
    raise value
AttributeError: 'PosixPath' object has no attribute 'subject'
```


### Browser logs

```bash
Run
```


### Paperless-ngx version

1.6.3

### Host OS

Debian 11

### Installation method

Docker - official image

### Browser

-

### Configuration changes

-

### Other

-


Discussion:

Resolving patch:
diff --git a/src/paperless_mail/parsers.py b/src/paperless_mail/parsers.py
--- a/src/paperless_mail/parsers.py
+++ b/src/paperless_mail/parsers.py
@@ -33,7 +33,9 @@ class MailDocumentParser(DocumentParser):
 
     def get_thumbnail(self, document_path: Path, mime_type: str, file_name=None):
         if not self.archive_path:
-            self.archive_path = self.generate_pdf(document_path)
+            self.archive_path = self.generate_pdf(
+                self.parse_file_to_message(document_path),
+            )
 
         return make_thumbnail_from_pdf(
             self.archive_path,
@@ -300,9 +302,6 @@ def generate_pdf_from_mail(self, mail: MailMessage) -> Path:
         css_file = Path(__file__).parent / "templates" / "output.css"
         email_html_file = self.mail_to_html(mail)
 
-        print(css_file)
-        print(email_html_file)
-
         with css_file.open("rb") as css_handle, email_html_file.open(
             "rb",
         ) as email_html_handle:


Test patch:
diff --git a/src/paperless_mail/tests/test_parsers.py b/src/paperless_mail/tests/test_parsers.py
--- a/src/paperless_mail/tests/test_parsers.py
+++ b/src/paperless_mail/tests/test_parsers.py
@@ -293,9 +293,7 @@ def test_get_thumbnail(
             "message/rfc822",
         )
 
-        mock_generate_pdf.assert_called_once_with(
-            test_file,
-        )
+        mock_generate_pdf.assert_called_once()
         mock_make_thumbnail_from_pdf.assert_called_once_with(
             "Mocked return value..",
             self.parser.tempdir,