|
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
martin f. krafft
wrote on Mon, 13 Jun 2011 13:50 |
http://git.madduck.net/v/etc/mutt.git/blob/HEAD:/.mutt/sendmail-checks.d/check-attachments
Reply
|
Re: How to not embarrass yourself with missing attachments in mutt
Gerfried Fuchs
wrote on Tue, 14 Jun 2011 07:39 |
Are we a bit revinventing the wheel here? ;) http://mako.cc/projects/attachcheck/ - and this run through planet debian too ;)
Reply
|
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
|
Re: How to not embarrass yourself with missing attachments in mutt
Paul Csanyi
wrote on Fri, 28 Dec 2012 06:41 |
OK, the script works but then in Mutt, how can I actually add the header X-attached: none ??
Reply
|
Re: How to not embarrass yourself with missing attachments in mutt
Paul Csanyi
wrote on Fri, 28 Dec 2012 06:42 |
OK, the script works but then in Mutt, how can I actually add the header X-attached: none ??
Reply
|
Re: Re: How to not embarrass yourself with missing attachments in mutt
Steve
wrote on Wed, 02 Jan 2013 18:01 |
(replying here and by mail, for convenience) When sending the message fails, re-edit and add that as a header. To make it more obvious, I also add: my_hdr X-attached: unknown into my .muttrc so there's a header field there waiting for me to use
Reply
|
|