]>
git.immae.eu Git - perso/Immae/Projets/Scripts/Public.git/blob - mutt_check_attachment
3 ## Original script adapted from source: http://wiki.mutt.org/?ConfigTricks/CheckAttach
5 ## Adapted by Ismaël Bouya (http://www.normalesup.org/~bouya/) to make it so
6 ## that retrying to send the email shortly after will work
8 ## Edit muttrc to have this line:
9 ## set sendmail = "/usr/local/bin/mutt_check_attachment_before_send.sh /usr/lib/sendmail -oem -oi"
13 ## Attachment keywords that the message body will be searched for:
14 KEYWORDS
= 'attach|joint|voici|voil'
16 ## Check that sendmail or other program is supplied as first argument.
17 if [ ! -x " $1 " ]; then
18 echo "Usage: $0 </path/to/mailprog> <args> ..."
19 echo "e.g.: $0 /usr/sbin/sendmail -oem -oi"
23 ## Save msg in file to re-use it for multiple tests.
24 TMPFILE
= `mktemp -t mutt_checkattach.XXXXXX` || exit 2
27 ## Define test for multipart message.
29 # grep -q '^Content-Type: multipart' "$TMPFILE"
30 grep -q '^Content-Disposition: attachment' " $TMPFILE "
33 ## Define test for keyword search.
34 function word
-attach {
35 grep -v '^>' " $TMPFILE " | grep -E -i -q " $KEYWORDS "
39 function header
-override {
40 grep -i -E "^X-attached: *none *$" " $TMPFILE "
45 dialog
--yesno "Envoyer malgré la pièce jointe manquante ?" 5 30 < $terminal > $terminal
48 #Verifie qu'on a essayé de l'envoyer y'a moins d'une minute
50 if [ ! -e $HOME / .mutt_attach
]; then
53 valeur
= `echo \` date +% s\
`-\` stat
-c % Y
$HOME / .mutt_attach\
`'<60' | bc`
57 if multipart
|| ! word
-attach || header
-override || ! file_last
; then
60 if [ ! -s $HOME / .mutt_attach
]; then
61 rm -f $HOME / .mutt_attach
64 echo "No file was attached but a search of the message text suggests there should be one. Add a header \" X-attached: none \" to override this check if no attachment is intended."
65 echo "You can also send the email again in the next minute."
67 touch $HOME / .mutt_attach
70 ## Delete the temporary file.