Github messages for mblaze
 help / color / mirror / Atom feed
From: nmeum <nmeum@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] mrep: Set From header according to To/Cc header
Date: Mon, 20 Apr 2020 15:43:26 +0200	[thread overview]
Message-ID: <20200420134326.9zGxVpxmoGLMKOybNSnBXS7e0vJ04qd4IJQ1bmM2EhE@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-fa6558a0-26e0-48f6-803f-f5a8af34f6a8-mblaze-173@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]

There is an updated pull request by nmeum against master on the mblaze repository

https://github.com/nmeum/mblaze mrep-check-to-and-cc
https://github.com/leahneukirchen/mblaze/pull/173

mrep: Set From header according to To/Cc header
I use different mail addresses for different purposes. When replying to
any email, `mrep(1)` currently uses the mail address configured as
`Local-Mailbox` for the From header. While generally desirable, I do not
want to reply to mails I received through my work address with my
private email address.

This commit introduces a change which uses the email address, the email
was sent to, (as specified by To/Cc) for the From header, as long as this
address was configured as an `Alternate-Mailboxes`. I just quickly hacked
this together as a proof of concept without much further considerations.
Seems to work though but not sure if it is generally desirable to enable
this behaviour by default, let me know what you think.

A patch file from https://github.com/leahneukirchen/mblaze/pull/173.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-mrep-check-to-and-cc-173.patch --]
[-- Type: text/x-diff, Size: 5895 bytes --]

From 32e65c842962f038b4a59d0b76928001ff9a187d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Mon, 30 Mar 2020 11:31:18 +0200
Subject: [PATCH 1/4] mrep: Set From header according to To/Cc header

I use different mail addresses for different purposes. When replying to
any email, mrep(1) currently uses the mail address configured as
`Local-Mailbox` for the From header. While generally desirable, I do not
want to reply to mails I received through my work address with my
private email address.

This commit introduces a change which uses the email address the email
was sent to (as specified by To/Cc) for the From header, as long as this
address was configured as an `Alternate-Mailboxes`.
---
 mcom | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/mcom b/mcom
index e2f7100..9bfeecc 100755
--- a/mcom
+++ b/mcom
@@ -10,9 +10,9 @@ commajoin() {
 	     END {print l}'
 }
 
-notmine() {
+grepmine() {
 	mine="$(maddr -a -h local-mailbox:alternate-mailboxes: "$MBLAZE/profile")"
-	grep -Fv -e "$mine"
+	grep -F -e "$mine" "$@"
 }
 
 ouniq() {
@@ -349,14 +349,15 @@ fi
 			printf 'To: %s\n' "$to"
 			printf 'Cc: %s\n' \
 			       "$(mhdr -d -A -h to:cc: "$1" |
-				       notmine |grep -Fv -e "$to" |
+				       grepmine -v |grep -Fv -e "$to" |
 				       ouniq |commajoin)"
 			printf 'Bcc: \n'
 			printf '%s\n' "$hdrs" | awk '{ print }' |
 				msed "/body/d" /dev/stdin
 		fi | sed '/^$/d'
 		printf 'Subject: Re: %s\n' "$(COLUMNS=10000 mscan -f '%S' "$1")"
-		from=$(mhdr -h local-mailbox "$MBLAZE/profile")
+		from=$(mhdr -d -A -h to:cc: "$1" | grepmine | head -n 1)
+		[ -z "$from" ] && from=$(mhdr -h local-mailbox "$MBLAZE/profile")
 		[ "$from" ] && printf 'From: %s\n' "$from"
 		mid=$(mhdr -h message-id "$1")
 		if [ "$mid" ]; then

From 6c54a1e08917a24ce92f8ee72dd92377317f9cec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Mon, 30 Mar 2020 19:36:31 +0200
Subject: [PATCH 2/4] fixup! mrep: Set From header according to To/Cc header

---
 mcom | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/mcom b/mcom
index 9bfeecc..70c46f8 100755
--- a/mcom
+++ b/mcom
@@ -356,8 +356,12 @@ fi
 				msed "/body/d" /dev/stdin
 		fi | sed '/^$/d'
 		printf 'Subject: Re: %s\n' "$(COLUMNS=10000 mscan -f '%S' "$1")"
-		from=$(mhdr -d -A -h to:cc: "$1" | grepmine | head -n 1)
-		[ -z "$from" ] && from=$(mhdr -h local-mailbox "$MBLAZE/profile")
+
+		from=$(mhdr -h local-mailbox "$MBLAZE/profile")
+		addr=$(maddr -a -h to:ccc:bcc: "$1" | grepmine | head -n 1)
+		[ -n "$addr" ] && from=$(printf "%s <%s>" \
+			"$(maddr -d -h "local-mailbox" "$MBLAZE/profile")" "$addr")
+		
 		[ "$from" ] && printf 'From: %s\n' "$from"
 		mid=$(mhdr -h message-id "$1")
 		if [ "$mid" ]; then

From ec156e0fc4795e702fa7544915bc2d7e2b1514e9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Mon, 30 Mar 2020 19:46:11 +0200
Subject: [PATCH 3/4] fixup! mrep: Set From header according to To/Cc header

---
 mcom | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mcom b/mcom
index 70c46f8..c0f80d0 100755
--- a/mcom
+++ b/mcom
@@ -358,7 +358,7 @@ fi
 		printf 'Subject: Re: %s\n' "$(COLUMNS=10000 mscan -f '%S' "$1")"
 
 		from=$(mhdr -h local-mailbox "$MBLAZE/profile")
-		addr=$(maddr -a -h to:ccc:bcc: "$1" | grepmine | head -n 1)
+		addr=$(maddr -a -h to:cc:bcc: "$1" | grepmine | head -n 1)
 		[ -n "$addr" ] && from=$(printf "%s <%s>" \
 			"$(maddr -d -h "local-mailbox" "$MBLAZE/profile")" "$addr")
 		

From 30dd0131141e8f72d5aebfd4c2840920d8f7ca75 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Mon, 20 Apr 2020 15:20:27 +0200
Subject: [PATCH 4/4] mrep: Set From header according to To/Cc/Bcc header

If any of the address contained in the aforementioned headers matches an
address configured in the Reply-From header in mblaze-profile(5).

Without this change, mrep(1) uses the mail address configured as
Local-Mailbox for the From header. While generally desirable, I use
different mail addresses for different proposes. As such, I do not
want to reply to mails I received through my work address with my
private email address.
---
 man/mblaze-profile.5 |  3 +++
 mcom                 | 15 ++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/man/mblaze-profile.5 b/man/mblaze-profile.5
index e1fa01c..11fad7b 100644
--- a/man/mblaze-profile.5
+++ b/man/mblaze-profile.5
@@ -44,6 +44,9 @@ to recognize messages sent to you.
 A comma-separated list of mail addresses that also belong to you, for
 .Xr mscan 1
 to recognize messages sent by or directly to you.
+.It Li Reply-From\&:
+A comma-separated list of mail addresses that are automatically used for
+the From header in a reply if present in the Cc, To, or Bcc header.
 .It Li FQDN\&:
 The fully qualified domain name used for
 .Li Message\&-Id\&:
diff --git a/mcom b/mcom
index c0f80d0..674def5 100755
--- a/mcom
+++ b/mcom
@@ -15,6 +15,11 @@ grepmine() {
 	grep -F -e "$mine" "$@"
 }
 
+replyfrom() {
+	addrs="$(maddr -a -h reply-from "$MBLAZE/profile")"
+	grep -Fv -e "addrs"
+}
+
 ouniq() {
 	awk '!seen[$0]++'
 }
@@ -357,7 +362,15 @@ fi
 		fi | sed '/^$/d'
 		printf 'Subject: Re: %s\n' "$(COLUMNS=10000 mscan -f '%S' "$1")"
 
-		from=$(mhdr -h local-mailbox "$MBLAZE/profile")
+		addr=$(maddr -a -h to:cc:bcc: "$1" | replyfrom | head -n1)
+		if [ -n "$addr" ]; then
+			from=$(maddr -h reply-from "$MBLAZE/profile" | \
+				awk "/$addr/ { print; exit }" | head -n1)
+		fi
+		if [ -z "$from" ]; then
+			from=$(mhdr -h local-mailbox "$MBLAZE/profile")
+		fi
+
 		addr=$(maddr -a -h to:cc:bcc: "$1" | grepmine | head -n 1)
 		[ -n "$addr" ] && from=$(printf "%s <%s>" \
 			"$(maddr -d -h "local-mailbox" "$MBLAZE/profile")" "$addr")

  parent reply	other threads:[~2020-04-20 13:43 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <gh-mailinglist-notifications-fa6558a0-26e0-48f6-803f-f5a8af34f6a8-mblaze-173@inbox.vuxu.org>
2020-03-30 11:22 ` nmeum
2020-03-30 11:59 ` leahneukirchen
2020-03-30 12:05 ` Duncaen
2020-03-30 12:08 ` Duncaen
2020-03-30 12:09 ` Duncaen
2020-03-30 12:16 ` Duncaen
2020-03-30 12:54 ` nmeum
2020-03-30 13:04 ` leahneukirchen
2020-03-30 14:49 ` nmeum
2020-03-30 14:56 ` leahneukirchen
2020-03-30 17:37 ` [PR PATCH] [Updated] " nmeum
2020-03-30 17:37 ` nmeum
2020-03-30 17:46 ` [PR PATCH] [Updated] " nmeum
2020-03-30 17:48 ` nmeum
2020-03-30 17:50 ` leahneukirchen
2020-03-30 17:56 ` nmeum
2020-03-30 17:56 ` nmeum
2020-03-30 17:56 ` nmeum
2020-03-30 17:57 ` nmeum
2020-03-30 18:02 ` leahneukirchen
2020-03-30 18:04 ` leahneukirchen
2020-03-30 18:44 ` nmeum
2020-04-20 13:43 ` nmeum [this message]
2020-04-20 13:44 ` [PR PATCH] [Updated] " nmeum
2020-04-20 13:50 ` nmeum
2020-04-20 13:51 ` nmeum
2020-04-20 13:55 ` nmeum
2020-04-20 13:55 ` nmeum
2020-04-20 13:58 ` leahneukirchen
2020-04-20 14:08 ` [PR PATCH] [Updated] " nmeum
2020-04-20 14:12 ` nmeum
2020-04-20 14:20 ` [PR PATCH] [Updated] " nmeum
2020-04-20 14:25 ` nmeum
2020-05-20  1:40 ` xelxebar
2020-05-20  1:41 ` xelxebar
2020-05-23 13:43 ` leahneukirchen
2020-05-23 14:02 ` leahneukirchen
2020-09-06 14:30 ` [PR PATCH] [Closed]: " leahneukirchen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200420134326.9zGxVpxmoGLMKOybNSnBXS7e0vJ04qd4IJQ1bmM2EhE@z \
    --to=nmeum@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).