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

Re: send-hook -> pipe_message



On 28/06/04 13.52, Ben Livingood wrote:
> Ok, I think I'm going about this the wrong way. I have downloaded lbdb
> and want to pipe outgoing mails through it [building a list of
> addresses that routinely email to]. 
> 
> Is this even possible? My reading of the manual seems to point towards
> it not being so, but I'd be glad to be wrong. 
> I had thought that something like
> 
> send-hook . '<pipe-message>lbdb-fetchaddr<enter>'
> 
> would work, but that's seems to execute before the mail message is put
> together. 

Because send-hooks are designed to setup things for the mail you are
about to compose they are indeed executed before the message is passed
to the editor.

One way to get the kind of result you are looking for is to do a
wrapper script for sendmail.

From 'man muttrc':
       sendmail
              Type: path
              Default: "/usr/sbin/sendmail -oem -oi"

              Specifies the program and arguments used to deliver mail
              sent by Mutt.   Mutt expects that the specified program
              interprets additional arguments as recipient addresses.

So if you put 'set sendmail=$HOME/bin/my-sendmail' or something in
your .muttrc, and a suitable script in ~/bin/my-sendmail, you have
access to the mail at the right time.

Just thinking out loud, you may want something like this for the
script (Untested code, std. warnings apply, test and use with care):

  #!/usr/bin/env bash
  umask 0077
  ARGS="$@"
  FILE="/tmp/mail-$(whoami)-$$" #Or whatever you like to create unique
                                #names for temporary user files.
  cat > $FILE
  cat $FILE | lbdb-fetchaddr
  cat $FILE | /usr/sbin/sendmail -oem -oi $ARGS
  rm -f $FILE

Something like this can be leveraged to do any number of additional
actions on outgoing mail (I use somethin similar with ssh as MTA to
avoid having sendmail on some machines, where only my user needs to
send mail), and if you find that you need it you have access to the
arguments to sendmail as well (those are the addresses that mutt is
actually trying to send the mail to). Plus you can do any kind of
editing you like, either to the outgoing mail, or more likely to a
copy used for other purposes.

HTH, HAND.

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

Attachment: pgpYZxPO6O46N.pgp
Description: PGP signature