Skip to content

Commit 4dc596e

Browse files
committed
fix(mimefactory): do not wrap MDNs into multipart/mixed part
1 parent 2e69210 commit 4dc596e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/mimefactory.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,30 @@ impl<'a> MimeFactory<'a> {
768768
.build(),
769769
)
770770
.header(("Subject".to_string(), "...".to_string()))
771+
} else if matches!(self.loaded, Loaded::Mdn { .. }) {
772+
// Never add outer multipart/mixed wrapper to MDN
773+
// as multipart/report Content-Type is used to recognize MDNs
774+
// by Delta Chat receiver and Chatmail servers
775+
// allowing them to be unencrypted and not contain Autocrypt header
776+
// without resetting Autocrypt encryption or triggering Chatmail filter
777+
// that normally only allows encrypted mails.
778+
779+
// Hidden headers are dropped.
780+
781+
// Store protected headers in the outer message.
782+
let message = headers
783+
.protected
784+
.iter()
785+
.fold(message, |message, header| message.header(header.clone()));
786+
787+
let protected: HashSet<Header> = HashSet::from_iter(headers.protected.into_iter());
788+
for h in headers.unprotected.split_off(0) {
789+
if !protected.contains(&h) {
790+
headers.unprotected.push(h);
791+
}
792+
}
793+
794+
message
771795
} else {
772796
// Store hidden headers in the inner unencrypted message.
773797
let message = headers

0 commit comments

Comments
 (0)