[PATCH] reverse_name: optionally read {,X-}Envelope-To:
Tobias Girstmair
t-mutt at girst.at
Thu May 16 18:25:53 UTC 2019
By setting $reverse_envelopeto the reverse_name functionality is
extended to also search the Envelope-To: and X-Envelope-To: headers when
looking for a suitable From: address.
---
Hello, mutt developers!
This is a feature which has been talked about at least three times, but
was never implemented. Since I didn't dare to change the default
behaviour, this change is only active when $reverse_envelopeto is set in
e.g. muttrc. In one of the earlier discussions, the "Delivered-To:"
header came up, but I have deliberately _not_ included it, because in
the mails I've analyzed this points to the mailing list's address.
https://marc.info/?l=mutt-dev&m=105521847425877&w=2
https://marc.info/?l=mutt-dev&m=124474341901084&w=2
https://marc.info/?l=mutt-users&m=145645204904724&w=2
I'd love to hear your feedback (and to have this merged, of course) ;-)
greetings,
tobias
contrib/sample.muttrc | 1 +
init.h | 8 ++++++++
mutt.h | 2 ++
send.c | 17 ++++++++++++++---
4 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/contrib/sample.muttrc b/contrib/sample.muttrc
index be264466..142c33c4 100644
--- a/contrib/sample.muttrc
+++ b/contrib/sample.muttrc
@@ -79,6 +79,7 @@ set reply_to # always use reply-to if present
#set reverse_alias # attempt to look up my names for people
set reverse_name # use my address as it appears in the message
# i am replying to
+#set reverse_envelopeto # also look in {,X-}Envelope-To for reverse_name
set nosave_empty # remove files when no messages are left
#set save_name # save outgoing messages by recipient, if the
#set sendmail="/usr/lib/sendmail -oi -oem" # how to deliver mail
diff --git a/init.h b/init.h
index dcb157f0..eb31e797 100644
--- a/init.h
+++ b/init.h
@@ -2932,6 +2932,14 @@ struct option_t MuttVars[] = {
** possibly including eventual real names. When it is \fIunset\fP, mutt will
** override any such real names with the setting of the $$realname variable.
*/
+ { "reverse_envelopeto", DT_BOOL, R_BOTH, OPTREVENVELOPETO, 0 },
+ /*
+ ** .pp
+ ** This variable fine-tunes the behavior of the $$reverse_name feature.
+ ** When it is \fIset\fP, mutt will check the \fIEnvelope-to:\fP and
+ ** \fIX-Envelope-to:\fP ** headers, in addition to \fITo:\fP, \fICC:\fP and
+ ** \fIFrom:\fP.
+ */
{ "rfc2047_parameters", DT_BOOL, R_NONE, OPTRFC2047PARAMS, 0 },
/*
** .pp
diff --git a/mutt.h b/mutt.h
index 71b66657..aada2ae7 100644
--- a/mutt.h
+++ b/mutt.h
@@ -488,6 +488,7 @@ enum
OPTREVALIAS,
OPTREVNAME,
OPTREVREAL,
+ OPTREVENVELOPETO,
OPTRFC2047PARAMS,
OPTSAVEADDRESS,
OPTSAVEEMPTY,
@@ -671,6 +672,7 @@ typedef struct envelope
ADDRESS *sender;
ADDRESS *reply_to;
ADDRESS *mail_followup_to;
+ ADDRESS *envelope_to;
char *list_post; /* this stores a mailto URL, or nothing */
char *subject;
char *real_subj; /* offset of the real subject */
diff --git a/send.c b/send.c
index 7c1460c3..cd32eff0 100644
--- a/send.c
+++ b/send.c
@@ -1037,10 +1037,21 @@ static ADDRESS *set_reverse_name (ENVELOPE *env)
{
ADDRESS *tmp;
- for (tmp = env->to; tmp; tmp = tmp->next)
+ if (option (OPTREVENVELOPETO))
{
- if (mutt_addr_is_user (tmp))
- break;
+ for (tmp = env->envelope_to; tmp; tmp = tmp->next)
+ {
+ if (mutt_addr_is_user (tmp))
+ break;
+ }
+ }
+ if (!tmp)
+ {
+ for (tmp = env->to; tmp; tmp = tmp->next)
+ {
+ if (mutt_addr_is_user (tmp))
+ break;
+ }
}
if (!tmp)
{
--
2.20.1
More information about the Mutt-dev
mailing list