Re: reminder for missing attachment
- To: mutt-users@xxxxxxxx
- Subject: Re: reminder for missing attachment
- From: bill lam <cbill.lam@xxxxxxxxx>
- Date: Fri, 16 Jan 2009 23:30:26 +0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:mail-followup-to:references:mime-version:content-type :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=4DKmGPb8p+EA75N6Elxr/bRaPyd+OjJYIrEa9QGzDT4=; b=rcGKz0nbabQREr98xn0up92+19ZYXdXCo6el4gWIIbvR81jA7Bluaxr/JDafUlRCRK 9yRckfgpRK1zzHtZHUOXrohfuo3HYKgmbiKSnemUcRQrbbDYC0Iuhz/arE9qKw3TtZA7 gMt9zc6cyGyJfPAs3HKFuVgwgSxWQ1tQrgItk=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; b=iM6dxUh6ZRf9F5FetB+V87+Sgc7GwrQzo4XmlO5bcijv+H4DzbCrgQyU2k7ZYN/U+H 73HOtVxxQgPOyLrRuldwQW6ZecosOn5+lHee2tzcYDu38gQR7wSf3kzgOuaulq9cBFXL m0fW/8SG7ispnA/rnvfhA7jngAjT1V+S0tJW0=
- In-reply-to: <20090116091203.GB3197@xxxxxxxxxx>
- List-post: <mailto:mutt-users@mutt.org>
- List-unsubscribe: send mail to majordomo@mutt.org, body only "unsubscribe mutt-users"
- Mail-followup-to: mutt-users@xxxxxxxx
- References: <20090116062743.GC6984@b2j> <20090116091203.GB3197@xxxxxxxxxx>
- Sender: owner-mutt-users@xxxxxxxx
- User-agent: Mutt/1.5.19 (2009-01-05)
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