MIME header: X-Content-Encryption

Issue Description

In the PGP/MIME encryption at rest feature, Stalwart inserts a hardcoded inline text body (OpenPGP/MIME message (Automatically encrypted by Stalwart)) inside the top-level multipart boundary if it encrypts itself the message.

This should be replaced by a dedicated MIME header: X-Content-Encryption: on-delivery.

Expected Behavior

When fetching message header, we should get a such information.

Actual Behavior

Instead, we have to download the message Blob and do use a regex to determinate if the message was encrypted by sender or by server

Stalwart Version

v0.16.x

Installation Method

Binary (Linux)

Database Backend

PostgreSQL

Blob Storage

Filesystem

Search Engine

Internal

Directory Backend

OIDC

Additional Context

I can provide the PR, but the fix would be very simple, in crates/email/src/message/crypto.rs, just replace

concat!(
"\"\r\n\r\n",
 "OpenPGP/MIME message (Automatically encrypted by Stalwart)\r\n\r\n",
 "--"
)

by

concat!(
"\"\r\n",
"X-Content-Encryption: on-delivery\r\n\r\n",
"--"
)

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

This confirms the current implementation matches what’s described: an inline text body is hardcoded rather than exposing encryption status as a MIME header. This is a feature request rather than a documented behavior, so there’s no existing doc guidance to point to for a workaround.

I’ve confirmed this in the source at crates/email/src/message/crypto.rs, and the current code indeed inserts the hardcoded text body exactly as described, with no X-Content-Encryption header alternative available today. This is a reasonable feature request; a human maintainer will need to evaluate and decide whether to implement it, since it involves a behavior/format change to encrypted message output.

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

Please add this to the Feature Ideas category as it is not a bug or issue.