|
About
Steve's blog, The Words of the Sledge
steve@einval.com
Subscribe
Subscribe to the RSS feed.
Links
Home
Debian
PlanetDebian
Search PlanetDebian
Friends
Matthew Garrett
Jonathan McDowell
Jo McIntyre
Martin Michlmayr
Andrew Mobbs
Mike Pitt
Daniel Silverstone
Andy Simpkins
Neil Williams
|
|
|
How to not embarrass yourself with missing attachments in mutt
I keep on seeing people sending messages saying "see attached file"
or similar in their emails, but then forgetting to actually attach the
file. I used to do it myself lots, but then with the help of some
ideas I found on the net I wrote the following script to use with
mutt. To use it, use the setting "set sendmail=" to point at it.
#!/bin/bash
#
# mutt-sendmail
# helper script to reduce embarrassment with mutt :-)
#
# Copyright 2011 Steve McIntyre
# GPL v2
###
# save msg in file to re-use it for multiple tests
###
TMPFILE=`mktemp -p ~/tmp -t mutt.XXXXXX` || exit 2
cat > $TMPFILE
## Attachment keywords that the message body will be searched for:
KEYWORDS='attach|patch'
## Define test for multipart message.
function multipart {
grep -q '^Content-Type: multipart' "$TMPFILE"
}
## Define test for keyword search.
function word-attach {
grep -v '^>' "$TMPFILE" | grep -v "^X-attached:" | grep -E -i -q "$KEYWORDS"
}
## Header override.
function header-override {
grep -i -E "^X-attached: *none *$" "$TMPFILE"
}
###
# FINAL DECISION:
# chain series of functions, use ! || && for logic connections,
###
if multipart || ! word-attach || header-override; then
formail -I bcc < $TMPFILE | /usr/lib/sendmail -oi -oem "$@"
status=$?
else
echo "No file was attached but a search of the message text suggests there"
echo "should be one. Add a header \"X-attached: none\" to override this"
echo "check if no attachment is intended."
status=1
fi
rm -f $TMPFILE
exit $status
15:31 ::
# ::
/debian/mutt ::
6 comments
Re: How to not embarrass yourself with missing attachments in mutt
Robert Svoboda
wrote on Tue, 12 Jul 2011 16:06 |
also http://wiki.mutt.org/?ConfigTricks/CheckAttach
Reply
|
|