Re: compose pipe-message
Hi Dave,
Thanks for your reply. The macro method I described does not actually
have the problems you mention. Since the macro executes on the 'y' key
in compose mode, it is executed whenever an email is sent and without
any extra keystrokes to remember.
macro compose y "<enter-command>unset wait_key\n<pipe-entry>bogofilter
-n\n<enter-command>set wait_key\n<send-message>"
However, a sendmail wrapper script is also a good solution and since there
exists no pipe-message in compose mode. I have written such a wrapper. The
script is quite a bit longer than the macro, but it does have the advantage
of being usable outside of mutt. The script is attached.
-James
On Mon, Jul 05, 2004 at 02:06:06PM +0100, Dave Pearson wrote:
> * james@xxxxxxxxxxx <james@xxxxxxxxxxx> [2004-07-05 03:20:42 -0700]:
>
> > I've setup a macro to train bogofilter on outgoing email in addition to
> > incoming. The pipe-entry function appears to only pipe the body of the
> > message. The documentation does not list pipe-message as an available
> > function in compose mode. Is there currently a way to pipe the entire body
> > of a message to bogofilter before sending?
>
> Not really an answer to your question but I was wondering why you'd do it
> this way and not, instead, do the training on outgoing messages via a script
> that you point mutt's $sendmail variable at. That way you wouldn't have to
> remember to do the training and it would only train messages that you
> actually send.
>
> --
> Dave Pearson: | mutt.octet.filter - autoview octet-streams
> http://www.davep.org/ | mutt.vcard.filter - autoview simple vcards
> Mutt: | muttrc2html - muttrc -> HTML utility
> http://www.davep.org/mutt/ | muttrc.sl - Jed muttrc mode
#!/bin/sh
#
# sendmail.bogotrain is a sendmail wrapper which trains bogofilter on
# outgoing email which is classified as 100% non-spam.
#
# To use with mutt, add the following to your ~/.muttrc:
# set sendmail='/path/to/sendmail.bogotrain -oem -oi'
#
# For efficiency, this script uses a named fifo to copy stdin to sendmail
# using tee. This is safe with GNU tee since it ignores SIGPIPE.
#
# Copyright (C) 2004 James Klicman <james@xxxxxxxxxxx>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
SENDMAIL=/usr/sbin/sendmail
TMPDIR=/tmp
TMP_FIFO_DIR=`mktemp -d -q $TMPDIR/$(basename $0).XXXXXX`
if [ $? -ne 0 ]; then
# can't create temp fifo dir, abort training
exec $SENDMAIL "$@"
fi
SM_FIFO=$TMP_FIFO_DIR/fifo
trap "rm -f $SM_FIFO; rmdir $TMP_FIFO_DIR; exit" 1 2 15
mkfifo -m 0600 $SM_FIFO
if [ $? -ne 0 ]; then
# can't create fifo, abort training
rmdir $TMP_FIFO_DIR
exec $SENDMAIL "$@"
fi
$SENDMAIL "$@" <$SM_FIFO &
SM_PID=$!
tee $SM_FIFO | bogofilter -n
wait $SM_PID
SM_STATUS=$?
# clean up temp files
rm -f $SM_FIFO
rmdir $TMP_FIFO_DIR
exit $SM_STATUS