From: Thomas Roessler Date: Wed, 16 Feb 2000 11:43:21 +0000 (+0000) Subject: Generate mail-followup-to headers which contain the user's mail X-Git-Tag: mutt-1-1-5-rel~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=73d7225502e09dbc69a1d2b93cb1350385b62f95;p=mutt Generate mail-followup-to headers which contain the user's mail address when sending messages to _known_ mailing lists. --- diff --git a/pattern.c b/pattern.c index 300d3905..e56e7c2e 100644 --- a/pattern.c +++ b/pattern.c @@ -776,6 +776,17 @@ int mutt_is_list_recipient (int alladdr, ADDRESS *a1, ADDRESS *a2) return alladdr; } +int mutt_is_list_cc (int alladdr, ADDRESS *a1, ADDRESS *a2) +{ + for (; a1 ; a1 = a1->next) + if (alladdr ^ mutt_is_mail_list (a1)) + return (! alladdr); + for (; a2 ; a2 = a2->next) + if (alladdr ^ mutt_is_mail_list (a2)) + return (! alladdr); + return alladdr; +} + static int match_user (int alladdr, ADDRESS *a1, ADDRESS *a2) { for (; a1 ; a1 = a1->next) diff --git a/protos.h b/protos.h index 5874a189..75db0543 100644 --- a/protos.h +++ b/protos.h @@ -249,6 +249,7 @@ int mutt_invoke_sendmail (ADDRESS *, ADDRESS *, ADDRESS *, ADDRESS *, const char int mutt_is_autoview (BODY *, const char *); int mutt_is_mail_list (ADDRESS *); int mutt_is_message_type(int, const char *); +int mutt_is_list_cc (int, ADDRESS *, ADDRESS *); int mutt_is_list_recipient (int, ADDRESS *, ADDRESS *); int mutt_is_subscribed_list (ADDRESS *); int mutt_is_text_type (int, char *); diff --git a/send.c b/send.c index 1afafdab..631405af 100644 --- a/send.c +++ b/send.c @@ -789,23 +789,56 @@ generate_body (FILE *tempfp, /* stream for outgoing message */ void mutt_set_followup_to (ENVELOPE *e) { ADDRESS *t = NULL; + ADDRESS *from; - /* only generate the Mail-Followup-To if the user has requested it, and + /* + * Only generate the Mail-Followup-To if the user has requested it, and * it hasn't already been set */ + if (option (OPTFOLLOWUPTO) && !e->mail_followup_to) { - if (mutt_is_list_recipient (0, e->to, e->cc)) + if (mutt_is_list_cc (0, e->to, e->cc)) { - /* i am a list recipient, so set the Mail-Followup-To: field so that - * i don't end up getting multiple copies of responses to my mail + /* + * this message goes to known mailing lists, so create a proper + * mail-followup-to header */ + t = rfc822_append (&e->mail_followup_to, e->to); rfc822_append (&t, e->cc); - /* the following is needed if $metoo is set, because the ->to and ->cc - may contain the user's private address(es) */ - e->mail_followup_to = remove_user (e->mail_followup_to, 0); } + + /* remove ourselves from the mail-followup-to header */ + e->mail_followup_to = remove_user (e->mail_followup_to, 0); + + /* + * If we are not subscribed to any of the lists in question, + * re-add ourselves to the mail-followup-to header. The + * mail-followup-to header generated is a no-op with group-reply, + * but makes sure list-reply has the desired effect. + */ + + if (e->mail_followup_to && mutt_is_list_recipient (0, e->to, e->cc)) + { + if (e->from) + from = rfc822_cpy_adr (e->from); + else + from = mutt_default_from (); + + if (from) + { + /* Normally, this loop will not even be entered. */ + for (t = from; t && t->next; t = t->next) + ; + + t->next = e->mail_followup_to; /* t cannot be NULL at this point. */ + e->mail_followup_to = from; + } + } + + e->mail_followup_to = mutt_remove_duplicates (e->mail_followup_to); + } }