muratgozel / MIMEText

RFC-2822, RFC-2045 and RFC-2049 compliant raw email message generator.
https://muratgozel.github.io/MIMEText/
MIT License
82 stars 35 forks source link

Encoded Subject too long #53

Open falco467 opened 1 year ago

falco467 commented 1 year ago

According to RFC 2047 an encoded word cannot be longer than 76 characters (including everything). So a longer subject line should be split and encoded into multiple encoded words.

Using the library mgs.setSubject('x'.repeat(100)) results in a single standard breaking encoded word. This leads to some Mail-Servers rejecting this message with an error.

The encoding should split and wrap longer encoded words to match the standard.

muratgozel commented 9 months ago

hi @falco467 maybe we should add a strict (or loose) mode to trim subjects longer than 76 chars. im leaving this issue open to see how it goes.

falco467 commented 9 months ago

As far as I can see, all compliant clients will perform the line break after 76 characters. And I haven't seen any email client in the wild which doesn't parse the soft line breaks correctly. I don't think you necessarily need a "loose" mode to recreate the broken non-standard-compliant behavior.