Issue Description
When a message is created with JMAP Email/set using textBody, htmlBody and attachments, the attachments that have disposition “inline” and a cid referenced by the HTML part are placed next to the body in multipart/mixed, not grouped with the HTML part in multipart/related. Mail clients then do not show these images in the message body. In practice this happens with screenshots pasted into the body in the Bulwark webmail. Single node, otherwise default configuration.
Expected Behavior
The HTML part and the inline parts it references by cid are grouped in multipart/related (RFC 2387):
multipart/alternative
text/plain
multipart/related
text/html
image/png (inline, Content-ID)
wrapped in multipart/mixed when there are regular attachments as well.
Actual Behavior
multipart/mixed
multipart/alternative
text/plain
text/html (img src="cid:img1")
image/png (Content-Disposition: inline, Content-ID: img1)
The image is shown neither in the body by recipients’ mail clients nor in the webmail’s own Sent view.
Reproduction Steps
- Upload a PNG over JMAP (upload endpoint), get its blobId.
- Create a message with Email/set:
{
"mailboxIds": {"DRAFTS-ID": true},
"subject": "inline image test",
"bodyValues": {
"t": {"value": "see image"},
"h": {"value": "<p>see image</p><img src=\"cid:img1\">"}
},
"textBody": [{"partId": "t", "type": "text/plain"}],
"htmlBody": [{"partId": "h", "type": "text/html"}],
"attachments": [{"blobId": "BLOB-ID", "type": "image/png", "name": "image.png",
"disposition": "inline", "cid": "img1"}]
}
- Download the created message (its blobId) and look at the MIME structure.
Relevant Log Output
No errors are logged: the message is created and delivered normally, only the MIME structure is wrong.
Stalwart Version
v1.x
Installation Method
Binary (Linux)
Database Backend
RocksDB
Blob Storage
RocksDB
Search Engine
Internal
Directory Backend
Internal
Additional Context
Client: Bulwark 1.18.0 webmail, it creates drafts with textBody, htmlBody and attachments. Reverse proxy: nginx (not involved).
From the source: the Email/set handler in the jmap crate passes all JMAP attachments to the attachments list of the mail-builder MessageBuilder, and write_body_parts in mail-builder 2.0.0 always wraps the alternative part and the attachments in multipart/mixed and never creates multipart/related (inline() adds to the same list).
I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.
on
I have searched this support forum (open and closed topics) and confirm this is not a duplicate.
on
I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.
on