How to match a string like '+447537170394 <sms at aa.net.uk>' in a send hook?
Tapani Tarvainen
mutt at tapanitarvainen.fi
Thu Sep 26 07:29:21 UTC 2024
On Wed, Sep 25, 2024 at 12:11:15PM +0100, Chris Green (cl at isbd.net) wrote:
> To clarify, whhen I get an E-Mail with a From: header like:-
>
> From: +447537170394 <sms at aa.net.uk>
>
> I want replies (i.e. the To: header) to go to:-
>
> To: Fred Bloggs <f.bloggs at another.address.co.uk>
>
>
> I can't seem to get mutt to do this for me, I'm sure it must be
> possible and, probably, quite easy.
There doesn't seem to be any clean way to do that with mutt alone.
One hack that kind of works is
message-hook . 'unmy_hdr To:'
message-hook "~f .*447537170394.*" 'my_hdr To: Fred Bloggs <f.bloggs at another.address.co.uk>'
There are two problems with it:
First, it doesn't replace the original address, just adds to it,
which may be acceptable if the original goes to a black hole anyway.
Second, it only works if you hit Reply when (or after) viewing the
message, not if you do it directly from the index view.
What's worse, it will remember the extra address until you view
another message: if you view a message from 447537170394 and then go
to the index and reply to another message from there without viewing
it first, it will remember that extra address. It would probably be
possible to fix that by unsetting the extra header with some other
hook, but I don't the time to test that now.
An alternative approach, if you use (or could use) $edit_headers,
would be using your editor to change the To: -header. With a smart
enough editor (say, emacs) it could automated completely.
--
Tapani Tarvainen
More information about the Mutt-users
mailing list