marlam / msmtp

SMTP client with sendmail compatible interface
https://marlam.de/msmtp
GNU General Public License v3.0
176 stars 36 forks source link

Keep the Full Name when using `--set-from-header=on` on a piece of mail which already has `From`. #168

Closed shamefulCake1 closed 1 month ago

shamefulCake1 commented 1 month ago

Could this feature be added?

I know that it is possible to set From explicitly with the -F option, but I don't want to parse the original message myself to extract it and keep.

marlam commented 1 month ago

It could be added, but...

The problem is that mail header format is a nightmare. See lines 15-30 of test-header-handling.sh for examples of horrors that are allowed by the standards. That's why the function msmtp_read_headers() that parses mail addresses in the From, To, Cc, Bcc headers needs a complicated state machine even though it ignores any non-address parts, i.e. names or comments.

So while it is possible to parse name information, it would be very difficult to achieve an implementation that is correct, reliable and robust. A half-assed version that only covers the simplest cases would not be acceptable since users could not rely on it.

So I personally think it is not worth the effort. But I would accept patches that implement this in an RFC comformant way ;)