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

Re: how to do something automatically on sending a message to specific recipients



On 11/04/05 09.12, Chris McCraw wrote:
> On Sat, Apr 09, 2005 at 09:08:03AM +1000, Troy Piggins wrote:
> > * Chris McCraw <fool@xxxxxxxxxxxxx> :
> > <snip>
> > > i need to filter messages sent to a certain recipient--she has a 
> > > significant
> > > amount of difficulty in reading my messages unless they are perfectly
> > > capitalized and punctuated.  i do not wish to filter every message i send,
> > > though.  my ideal solution to this appeared to be (in my .muttrc):
> > > 
> > >   send-hook '~t recipient@xxxxxxxxxxx' filter-entry /u/fool/filter.pl
> > <snip>
> > > i have verified the correct functioning of filter.pl when invoked via
> > > 'F' from the compose context, but i need this to work just in the context
> > > of that one recipient (it would be nice if it caught cc:'s to her, but if
> > > it doesn't, that's life).
> > 
> > According to the muttrc man page, the pattern ~C matches To: or Cc:,
> > and have you tried quotation marks around the command part of the
> > send-hook?
> > 
> > send-hook '~C recipient@xxxxxxxxxxx' 'filter-entry /u/fool/filter.pl'
> > 
> > I do not use this filter.pl you talk of, but I have send-hooks of
> > similar format and this works for me.
> 
> (i changed mine to use ~C and quote the command, but even so...)
> 
> unfortunately, this is what happens:
> 
> after entering the recipient@xxxxxxxxxxx and subject of a message, as
> mutt is invoking my editor, it reports:
> 
> filter-entry:  unknown command
> 
> in the status bar and then goes on to send the message without filtering
> my mail.  filter.pl is just a fairly simple perl script that behaves as
> such:
> 
> % echo "testing this.  and that."  | /u/fool/filter.pl
> Testing this.  And that.
> % 
> 
> filter.pl is world-readable/executable, and i am trying this with mutt-1.5.6i
> 
> can you show me an actual example of filter-entry (or whatever the correct
> equivalent turns out to be) usage with send-hook?

Problem is that hooks can't be used quite like this. The hook is
executed as soon as the message is created, before you start composing
it. And filter-entry needs to be called differently too.

Provided that '<filter-entry>/u/fool/filter.pl' is always the correct
thing to do on such a mail just before sending, something like:

  send-hook . 'bind compose y send-message'
  send-hook '~C recipient@xxxxxxxxxxx' 'macro compose y 
"<filter-entry>/u/fool/filter.pl<enter><send-message>" "filter and send"'

might work.

Or you could create a /u/fool/sendmail-filter script:

  #!/bin/sh
  /u/fool/filter.pl | sendmail "$@"

and do something like:

  send-hook . 'set sendmail="/usr/lib/sendmail -oi -oem"'
  send-hook '~C recipient@xxxxxxxxxxx' 'set sendmail="/u/fool/sendmail-filter 
-oi -oem"'

this might be a bit cleaner, provided that your filter can handle a
complete mail (otherwise some tricks with formail/perl/sed/whatever
could split and reasemble the mail for you, in the sendmail-filter
script).

Note that while I think the principle of these suggested solutions is
sound, I can't guarantee that they work _just_ as I have typed them.

Note also the send-hook . ... lines. They are important! Mutt does not
have a concept of per-mail state, as far as most variables are
concerned, so setting things back to normal as the first thing on new
mails is the thing to do.

/dossen
-- 
Common sense is the collection of prejudices acquired by age eighteen.
                -- Albert Einstein

Attachment: pgp8aSjpf9nWP.pgp
Description: PGP signature