diff --git a/src/headerdef.rs b/src/headerdef.rs index c899ac57f..28fb4877d 100644 --- a/src/headerdef.rs +++ b/src/headerdef.rs @@ -11,11 +11,20 @@ pub enum HeaderDef { To, Cc, Disposition, + + /// Used in the "Body Part Header" of MDNs as of RFC 8098. + /// Indicates the Message-ID of the message for which the MDN is being issued. OriginalMessageId, /// Delta Chat extension for message IDs in combined MDNs AdditionalMessageIds, + /// Outlook-SMTP-server replace the `Message-ID:`-header + /// and write the original ID to `X-Microsoft-Original-Message-ID`. + /// To sort things correctly and to not show outgoing messages twice, + /// we need to check that header as well. + XMicrosoftOriginalMessageId, + ListId, References, InReplyTo, diff --git a/src/mimefactory.rs b/src/mimefactory.rs index b89e981fd..06d8a6973 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -514,12 +514,6 @@ impl<'a> MimeFactory<'a> { )); } - // we could also store the message-id in the protected headers - // which would probably help to survive providers like - // Outlook.com or hotmail which mangle the Message-ID. - // but they also strip the Autocrypt header so we probably - // never get a chance to tunnel our protected headers in a - // cryptographic payload. unprotected_headers.push(Header::new( "Message-ID".into(), render_rfc724_mid(&rfc724_mid), diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 93966bd60..dfe3d4986 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -950,7 +950,8 @@ impl MimeMessage { } pub fn get_rfc724_mid(&self) -> Option { - self.get(HeaderDef::MessageId) + self.get(HeaderDef::XMicrosoftOriginalMessageId) + .or_else(|| self.get(HeaderDef::MessageId)) .and_then(|msgid| parse_message_id(msgid).ok()) } @@ -2749,4 +2750,27 @@ On 2020-10-25, Bob wrote: "mime-modified test – mime-modified *set*; simplify is always regarded as lossy." ); } + + #[async_std::test] + async fn test_x_microsoft_original_message_id() { + let t = TestContext::new().await; + let message = MimeMessage::from_bytes(&t, b"Date: Wed, 17 Feb 2021 15:45:15 +0000\n\ + Chat-Version: 1.0\n\ + Message-ID: \n\ + To: Bob \n\ + From: Alice \n\ + Subject: Message from Alice\n\ + Content-Type: text/plain\n\ + X-Microsoft-Original-Message-ID: \n\ + MIME-Version: 1.0\n\ + \n\ + Does it work with outlook now?\n\ + ") + .await + .unwrap(); + assert_eq!( + message.get_rfc724_mid(), + Some("Mr.6Dx7ITn4w38.n9j7epIcuQI@outlook.com".to_string()) + ); + } }