stalwartlabs / mail-parser

Fast and robust e-mail parsing library for Rust
https://docs.rs/mail-parser/
Apache License 2.0
298 stars 40 forks source link

Multipart messages do not capture content inside direct body #46

Closed mdsimmo closed 1 year ago

mdsimmo commented 1 year ago
Subject: Sneaky text
Content-Type: multipart/mixed; boundary="1"

I cannot be seen!!
--1
Content-Type: text/plain
Content-Disposition: inline

Hello
--1

In the above message, the text "I cannot be seen!!" is never read by mail-parser.

It is important to read this text because some email clients will display the text if they do not support multipart content.

mdecimus commented 1 year ago

RFC2046 states:

   NOTE:  These "preamble" and "epilogue" areas are generally not used
   because of the lack of proper typing of these parts and the lack of
   clear semantics for handling these areas at gateways, particularly
   X.400 gateways.  However, rather than leaving the preamble area
   blank, many MIME implementations have found this to be a convenient
   place to insert an explanatory note for recipients who read the
   message with pre-MIME software, since such notes will be ignored by
   MIME-compliant software.

Mail-parser is a MIME-compliant library and ignores both prelude and epilogue. If you need to read these sections you can access them using the raw offsets. However I do not see why you need to do that. All modern clients support MIME and will never display the prelude/epilogue sections unless parsing fails.