<<< Date Index >>>     <<< Thread Index >>>

Checking envelope-to header for reverse_name ?



Hi,

I am using address extensions to separate a number of lists that I subscribe
to (e.g. user-foo@xxxxxxxxxxx to subscribe to the foo list and
user-bar-devel@xxxxxxxxxxx to subscribe to a bar development list.) 

Now I'd like to use reverse_name to reply to mails that arrive via those
lists. The problem is that on mosts lists my address will not be in To: or Cc:
and thus mutt defaults to "From: user@xxxxxxxxxxx" instead of "From:
user-foo@xxxxxxxxxxx".


I like to have incoming mail in _one_ folder only so I can't use folder 
hooks to solve this.

What is needed is a way of accessing the envelope-to header in
set_reverse_name() to check agains my alternates if "To:" and "Cc:" don't 
contain any of my alternates. 

Since there is no standard for the MTA passing the envelop-to address to 
the MUA, this would need to be somewhat configurable.

Anybody willing to take this up?


One half baked workaround that I implemented so far is:
1. Have procmail save the envelop to (supplied by postfix in "X-Original-To: 
  user-foo@xxxxxxxxxxx") in "X-Label: user-foo@xxxxxxxxxxx" for emails that 
  dont have one of my alternates in To: or Cc:. (This makes the envelop
  header accessible in the x-label part of the message context)
2. Add a reply hook that checks if %y contains an @-sign and add
  a From: with %y. (  reply-hook '~y @' my_hdr "From: %y" )
3. Patched mutt to do expandos in mutt_message_hook() which is called 
  (among others) for reply-hooks and thus expands the %y to the envelope
  address. (the patch is attached)

The solution works but is far from perfect. It will keep the my_hdr even 
when composing a new mail. Using unmy_hdr (reply-hook . 'unmy_hdr From:') 
before the hook mentioned above only resets the header for replies not for 
newly composed mails. Using a send-hook with "unmy_hdr From:" removes that 
header when newly composing emails but also for replies. :-/


I've seen a couple of mutt developers using address extensions and I wonder 
how you solved that problem for yourselfs.

Cheers
-henrik


--- mutt-1.5.18_reply_hook_expandos/hook.c.orig 2008-01-30 05:26:50.000000000 
+0100
+++ mutt-1.5.18/hook.c  2009-06-10 17:49:16.000000000 +0200
@@ -331,6 +331,8 @@
   HOOK *hook;
   char buf[STRING];
 
+  char command_expanded[255];
+
   current_hook_type = type;
   
   err.data = buf;
@@ -343,7 +345,11 @@
 
     if (hook->type & type)
       if ((mutt_pattern_exec (hook->pattern, 0, ctx, hdr) > 0) ^ hook->rx.not)
-       if (mutt_parse_rc_line (hook->command, &token, &err) != 0)
+      {
+       memset (command_expanded, 0, sizeof (command_expanded));
+       mutt_make_string (command_expanded, sizeof (command_expanded), 
hook->command, ctx, hdr);
+
+       if (mutt_parse_rc_line (command_expanded, &token, &err) != 0)
        {
          FREE (&token.data);
          mutt_error ("%s", err.data);
@@ -351,6 +357,7 @@
          current_hook_type = 0;
          return;
        }
+      }
   }
   FREE (&token.data);
   current_hook_type = 0;