From 282de65079f2a5438df3632d1811219250ee18b8 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Sat, 23 May 2020 16:00:06 +0200 Subject: mrep: use Reply-From configuration to find From header This allows replying from different addresses than Local-Mailbox if they appear in To, Cc or Bcc. Idea and initial patch by @nmeum. --- mcom | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'mcom') diff --git a/mcom b/mcom index 205a1ce..693d5c4 100755 --- a/mcom +++ b/mcom @@ -15,6 +15,12 @@ notmine() { grep -Fv -e "$mine" } +replyfrom() { + addrs="$(maddr -a -h reply-from: "$MBLAZE/profile")" + [ -z "$addrs" ] && addrs="$(maddr -a -h alternate-mailboxes: "$MBLAZE/profile")" + grep -F -e "$addrs" +} + ouniq() { awk '!seen[$0]++' } @@ -358,8 +364,11 @@ fi printf 'Subject: Re: %s\n' "$(COLUMNS=10000 mscan -f '%S' "$1")" if ! printf '%s\n' "$hdrs" | awk '{ print }' | mhdr -h from: /dev/stdin >/dev/null; then - from=$(mhdr -h local-mailbox "$MBLAZE/profile") - [ "$from" ] && printf 'From: %s\n' "$from" + addr=$(maddr -a -h to:cc:bcc: "$1" | replyfrom | head -n1) + [ -n "$addr" ] && from=$(maddr -h reply-from "$MBLAZE/profile" | grep -Fi "<$addr>" | head -n1) + [ -n "$addr" ] && [ -z "$from" ] && from=$(maddr -h alternate-mailboxes "$MBLAZE/profile" | grep -Fi "<$addr>" | head -n1) + [ -z "$from" ] && from=$(mhdr -h local-mailbox "$MBLAZE/profile") + [ -n "$from" ] && printf 'From: %s\n' "$from" fi mid=$(mhdr -h message-id "$1") if [ "$mid" ]; then -- cgit 1.4.1