-
-
Notifications
You must be signed in to change notification settings - Fork 364
Open
Description
offlineimap fails to fetch one MIME-encoded message in my inbox. This message is a multipart/mixed containing two parts
- a multipart/alternative (plain text and HTML)
- a PDF attachment
Both alternatives of the first part use the following headers
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
and the content uses German umlauts, for example
die Anzahl der Nachfragen steigt und wir freuen uns, Sie darüber informieren zu können, dass wir den
Rechnungsversand umstellen: Künftig erhalten Sie Ihre Rechnung ressourcenschonend als PDF per E–Mail.
Sofern Sie mit der Umstellung einverstanden sind und Ihre E–Mailadresse gültig ist, müssen Sie nichts weiter tun.
Thunderbird does not have issues with this message.
I attached the failing message. I slightly anonymized it, and replaced the PDF with a simple dummy text. When I removed the attachment completely (so that only the multipart/alternative remained), the message was fetched correctly.
offlineimap v8.0.0, imaplib2 v3.06, Python v3.12.7, OpenSSL 3.4.0 22 Oct 2024
on Manjaro
Error message:
'ascii' codec can't encode characters in position 366-367: ordinal not in range(128)
Traceback:
File "/usr/lib/python3.12/site-packages/offlineimap/folder/Base.py", line 815, in copymessageto
new_uid = dstfolder.savemessage(uid, message, flags, rtime)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/offlineimap/folder/Maildir.py", line 409, in savemessage
tmpname = self.save_to_tmp_file(messagename, msg)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/offlineimap/folder/Maildir.py", line 359, in save_to_tmp_file
fd.write(msg.as_bytes(policy=output_policy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/email/message.py", line 208, in as_bytes
g.flatten(self, unixfrom=unixfrom)
File "/usr/lib/python3.12/email/generator.py", line 117, in flatten
self._write(msg)
File "/usr/lib/python3.12/email/generator.py", line 182, in _write
self._dispatch(msg)
File "/usr/lib/python3.12/email/generator.py", line 219, in _dispatch
meth(msg)
File "/usr/lib/python3.12/email/generator.py", line 286, in _handle_multipart
g.flatten(part, unixfrom=False, linesep=self._NL)
File "/usr/lib/python3.12/email/generator.py", line 117, in flatten
self._write(msg)
File "/usr/lib/python3.12/email/generator.py", line 182, in _write
self._dispatch(msg)
File "/usr/lib/python3.12/email/generator.py", line 219, in _dispatch
meth(msg)
File "/usr/lib/python3.12/email/generator.py", line 278, in _handle_multipart
self.write(subparts)
File "/usr/lib/python3.12/email/generator.py", line 420, in write
self._fp.write(s.encode('ascii', 'surrogateescape'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Metadata
Metadata
Assignees
Labels
No labels