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

Re: reminder for missing attachment



On Fri, 16 Jan 2009, Christian Brabandt wrote:
> I have seen several solutions for that. One is mentioned at the wiki¹, 
> ¹ http://wiki.mutt.org/?ConfigTricks/CheckAttach

Thank everyone for help.  I finally modify this checkattach to my
need. Yes it needs the 5MB zenity, not sure why that is so bloated, If
anyone can make it work with TUI query, please let me know.

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩137 劉長卿  新年作
    鄉心新歲切  天畔獨潸然  老至居人下  春歸在客先
    嶺猿同旦暮  江柳共風煙  已似長沙傅  從今又幾年
#!/bin/bash

SENDMAIL=/usr/bin/msmtp

###
# this script uses a GUI app called "zenity" to ask for confirmation,
# if not in GUI, just let it pass. If you want TUI (not GUI) query,
# which means you replace "zenity" with something else, then
# drop this DISPLAY check.
###
if [ -z "$DISPLAY" ]; then
    exec $SENDMAIL "$@"
fi

###
# save msg in file to re-use it for multiple tests
###
t=`mktemp -t mutt.XXXXXX` || exit 2
cat > $t

###
# define tests for: anything you can think of can be done.
# the return code of last exec'ed cmd is used in final decision below
###
function multipart {
    grep -q '^Content-Disposition: attachment' $t
}

function word-attach {
    grep -i -q -e '^[^>].*attach' $t
}

###
# query function must return "true" to let the msg pass.
###
function ask {
    zenity --question --title 'mutt' --text 'Send without attachment?'
}

###
# FINAL DECISION:
# chain series of functions, use ! || && for logic connections,
# see "man $SHELL" for more possibilites like grouping, dependencies.
###
if ! word-attach ||  multipart || ask; then
   $SENDMAIL "$@" < $t
    status=$?
else
    status=1
fi
rm -f $t
exit $status