leahneukirchen / mblaze

Unix utilities to deal with Maildir
Other
419 stars 48 forks source link

mrep: Use first instead of last delivered-to to set from address #233

Open xelxebar opened 1 year ago

xelxebar commented 1 year ago

Overview

Commit e1e5bfe5 introduces a potential regression against 282de650. In cases where there are multiple Delivered-To headers, it is most likely that we want mrep to populate the sender address from the most public-facing Delivered-To, i.e. the first one; however, at the moment we are setting it to the address in the final (i.e. topmost and most internal-facing) one.

Why?

We have a posix setup that aliases multiple addresses into a virtual mailbox---e.g. all mails going to mars.*@example.com get glommed into mars@example.com. The problem is that postfix aliases end up adding an additional Delivered-To header for each of these alias redirections. This is necessary to detect alias loops and related problems.

Patch points

The proposed change boils down to munging mcom:377. I believe we just need to reverse the order of headers passed to maddr and then tail -n 1 instead of head -n 1. However, it appears that maddr doesn't currently have a -M switch like mhdr, so maybe a patch there is needed as well?

Comments

Thoughts? Does the above sound reasonable?

xelxebar commented 1 year ago

@leahneukirchen @stacyharper Mind weighing in on this?

stacyharper commented 1 year ago

About the use case I had, I only had one Delivered-To. If the fix continue to pick it, rather than the useless To, it is okay to me. Choosing the first Delivered-To seems okay and predictable to me

leahneukirchen commented 1 year ago

I guess both could be argued for, e.g. if you have multiple alias expansions they'll all end up as a Delivered-To..

I agree that maddr should parse repeated headers.

leahneukirchen commented 1 year ago

I also found multiple mailing lists ending up as Delivered-To...

Anachron commented 8 months ago

Jumping on this, I received a mail on an account I've put into my Alternate-Mailboxes setting but when replying to it via mrep it reverts the From: to default.

Is there a setting which lets me always use the To: address if it's inside the Alternate-Mailboxes setting? I couldn't find such a thing inside mcom.

If not, I may open a PR.