niax / rust-email

Implementation of MIME Messages for Rust
MIT License
62 stars 34 forks source link

FromStr for Mailbox has surprising behaviour #35

Open golddranks opened 7 years ago

golddranks commented 7 years ago

FromStr parses the whole string into the address field. But if I have a from field like "Pyry Kontio pyry.kontio@drasa.eu", I'd expect it parse the first part into the name field and the part inside the <> into the address field.

If it seems hard to break current functionality, Mailbox would should at least provide another method for attempting to parse this. This surprising behaviour breaks some downstream crates too – I came here because I got noticed this behaviour on Lettre.

SamuelWAnderson45 commented 5 years ago

Your example doesn't have <> but I assume you meant Pyry Kontio <pyry.kontio@drasa.eu> Even with the <>, that isn't a syntactically valid From field; the Display Name needs to be quoted if it contains whitespace. See Originator fields and Address specification.