stalwartlabs / mail-builder

E-mail builder library for Rust
https://docs.rs/mail-builder/
Apache License 2.0
54 stars 17 forks source link

support format=flowed? #5

Open alexwennerberg opened 2 years ago

alexwennerberg commented 2 years ago
  1. I'm not sure whether this library should assume that a trailing space means that it should use quoted-printable instead of utf-7 -- what's the reasoning behind this?
  2. It would be nice to have a way to set format=flowed -- I put together some commits on https://github.com/alexwennerberg/mail-builder but I'm not sure if it's the best way to do it or something you want to support in this library
mdecimus commented 2 years ago

That is done to preserve the integrity of the message. According to RFC2045 section 6.7:

      [...] some MTAs (Message Transport Agents,
      programs which transport messages from one user to
      another, or perform a portion of such transfers) are
      known to pad lines of text with SPACEs, and others are
      known to remove "white space" characters from the end
      of a line.  [...]
alexwennerberg commented 2 years ago

@mdecimus

That's true, but the spec also says quoted-printable shouldn't be used for this purpose

https://www.ietf.org/rfc/rfc2646.html#section-4.1

[[Quoted-Printable]()] encoding SHOULD NOT be used with Format=Flowed unless absolutely necessary (for example, non-US-ASCII (8-bit) characters over a strictly 7-bit transport such as unextended SMTP). In particular, a message SHOULD NOT be encoded in Quoted-Printable for the sole purpose of protecting the trailing space on flowed lines unless the body part is cryptographically signed or encrypted (see Section 4.6).

It also appears in section 6.7 that white space stripping/adding is rare (and this was written in 1999) and degrades gracefully to non-flowed plaintext. Anecdotally, I see 7-bit-encoded format=flowed emails in my inbox

mdecimus commented 2 years ago

@alexwennerberg I'll keep this issue (as well the other two) open and as soon as I have some time I'll see how this can be improved.