Issue Description
Email/get returns null for header:List-Id:asText on messages that do have a List-Id header. The raw form header:List-Id is returned correctly, and asText works for other headers (for example header:X-Probe:asText). Clients that detect mailing lists by reading List-Id in the Text form (the form RFC 8621 explicitly allows for this header) see nothing.
Expected Behavior
RFC 8621, section 4.1.2.2 (Text form): “this form may only be fetched or set for the following header fields: Subject, Comments, Keywords, List-Id, Any header field not defined in [RFC5322] or [RFC2369].” So header:List-Id:asText should be "Probe list <probe-17925.example.com>".
Actual Behavior
null, both for a message imported with Email/import and for one created with Email/set (where the header was set through header:List-Id:asText and is stored correctly, as the raw form shows).
Reproduction Steps
- Import a message with these headers (blob upload +
Email/import):
From: Probe <[email protected]>
To: [email protected]
Subject: RE: Budget zq17925 planning
List-Id: Probe list <probe-17925.example.com>
List-Unsubscribe: <mailto:[email protected]>
X-Probe: yes
Content-Type: text/plain; charset=utf-8
hello
- Fetch it:
curl -s -u "[email protected]:$PASS1" -H 'Content-Type: application/json' https://mail.example.com/jmap/ -d '{
"using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
"methodCalls": [["Email/get", {"accountId": "c", "ids": ["qiaaaaec", "qmaaaaed"], "properties": [
"subject", "header:List-Id", "header:List-Id:asText", "header:X-Probe:asText",
"header:List-Unsubscribe:asURLs"]}, "g"]]}'
(qmaaaaed was created with Email/set and "header:List-Id:asText": "Set list <set-17925.example.com>".)
Response:
{"methodResponses": [["Email/get", {"accountId": "c", "state": "srqca", "list": [
{"subject": "RE: Budget zq17925 planning", "header:List-Id": " Probe list <probe-17925.example.com>",
"header:List-Id:asText": null, "header:X-Probe:asText": "yes",
"header:List-Unsubscribe:asURLs": ["mailto:[email protected]"], "id": "qiaaaaec"},
{"subject": "setprobe 17925", "header:List-Id": " Set list <set-17925.example.com>",
"header:List-Id:asText": null, "header:X-Probe:asText": "yes",
"header:List-Unsubscribe:asURLs": null, "id": "qmaaaaed"}], "notFound": []}, "g"]]}
Stalwart Version
v0.16.x
Installation Method
Docker
Database Backend
RocksDB
Blob Storage
RocksDB
Search Engine
Internal
Directory Backend
Internal
Additional Context
Where it seems to come from:
crates/email/src/message/headers.rs: for a structured header the stored, already parsed value is used (header.value.clone()), and the raw bytes are re-parsed only when the form is Raw or the header is not structured (is_raw = matches!(form, HeaderForm::Raw) || !header_name.is_structured()). List-Id is stored in its parsed address-like form, and converting that value to HeaderForm::Text gives null. Re-parsing the raw value with parse_unstructured() when Text is requested would fix it.
Stalwart v0.16.27, Docker image stalwartlabs/stalwart:v0.16-alpine, default setup from the bootstrap wizard.
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