]>
git.immae.eu Git - perso/Immae/Projets/Scripts/Public.git/blob - mutt_check_attachment
2365194d998b3881d0f758cc868572bde344af6c
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 # Feel like tipping/donating? https://www.immae.eu/licenses_and_tipping
16 ## Attachment keywords that the message body will be searched for:
17 KEYWORDS
= 'attach|joint|voici|voil'
19 ## Check that sendmail or other program is supplied as first argument.
20 if [ ! -x " $1 " ]; then
21 echo "Usage: $0 </path/to/mailprog> <args> ..."
22 echo "e.g.: $0 /usr/sbin/sendmail -oem -oi"
26 ## Save msg in file to re-use it for multiple tests.
27 TMPFILE
= `mktemp -t mutt_checkattach.XXXXXX` || exit 2
30 ## Define test for multipart message.
32 # grep -q '^Content-Type: multipart' "$TMPFILE"
33 grep -q '^Content-Disposition: attachment' " $TMPFILE "
36 ## Define test for keyword search.
37 function word
-attach {
38 grep -v '^>' " $TMPFILE " | grep -E -i -q " $KEYWORDS "
42 function header
-override {
43 grep -i -E "^X-attached: *none *$" " $TMPFILE "
48 dialog
--yesno "Envoyer malgré la pièce jointe manquante ?" 5 30 < $terminal > $terminal
51 #Verifie qu'on a essayé de l'envoyer y'a moins d'une minute
53 if [ ! -e $HOME / .mutt_attach
]; then
56 valeur
= `echo \` date +% s\
`-\` stat
-c % Y
$HOME / .mutt_attach\
`'<60' | bc`
60 if multipart
|| ! word
-attach || header
-override || ! file_last
; then
63 if [ ! -s $HOME / .mutt_attach
]; then
64 rm -f $HOME / .mutt_attach
67 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."
68 echo "You can also send the email again in the next minute."
70 touch $HOME / .mutt_attach
73 ## Delete the temporary file.