Skip to content

Read messages that Mail stores only as partial files - #7

Merged
mattt merged 1 commit into
mainfrom
mattt/read-partial-mail-messages
Oct 24, 2026
Merged

mattt merged 1 commit into
mainfrom
mattt/read-partial-mail-messages

Conversation

@mattt

@mattt mattt commented Oct 24, 2026

Copy link
Copy Markdown
Owner

In mattt/iMCP, mail_messages_read failed for 6 of the 15 newest messages in a real V10 store, with "Mail has downloaded only part of the message. Open the message in Mail to download it." In an earlier case, opening such a message in Mail did not make it readable. Each of these messages exists only as <rowid>.partial.emlx, and each of those files keeps the headers and the text parts. In 4 of the 6, some parts, such as attachments and inline images, have an empty body and an X-Apple-Content-Length header, and their content is in Attachments/<rowid>/<part>/. The other 2 have no such parts.

This PR makes the store read a message's .partial.emlx file when its mailbox has no complete .emlx file, with the same containment, size, and duplicate checks. A complete file still takes precedence, including over a cached partial location. Content.attachments lists the parts that have a filename or that Mail stores separately, with their media type and isStoredSeparately. attachmentFilenames now comes from this list.

A part that Mail stores separately cannot supply the body. When no other part can, Content throws EmlxError.partialMessage. Envelope no longer throws MailError.partialMessage, so this PR deprecates it, and its text no longer says that opening the message in Mail downloads it. The README and the MIME behavior specification describe partial files.

Mail writes <rowid>.partial.emlx when it stores some parts of a
message, such as attachments and inline images, in separate files.
The partial file keeps the headers and the text parts, and leaves the
body of each separate part empty, with an X-Apple-Content-Length field.
Envelope threw MailError.partialMessage for these messages.

The reader now reads the partial file when no complete .emlx file
exists, with the same containment and size checks. Content.attachments
lists the parts that have a filename or that Mail stores separately,
and isStoredSeparately marks the parts whose content the file leaves
out. A part that Mail stores separately cannot supply the body; when no
other part can, Content throws EmlxError.partialMessage.
MailError.partialMessage is deprecated, and its text no longer says
that opening the message in Mail downloads it.
@mattt
mattt merged commit a90202c into main Oct 24, 2026
4 checks passed
@mattt
mattt deleted the mattt/read-partial-mail-messages branch October 24, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant