This repository has been archived on 2023-01-25. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
mail-config/astroid/hooks/delmail

24 lines
728 B
Plaintext
Raw Normal View History

2017-07-24 15:30:04 +02:00
#!/bin/bash
#
# Deletes a mail permanently from the computer and the notmuch database
# Safeguard: only deletes a mail if it's tagged with $TAG, e.g. "del" or "trash"
#
# $1 = message id
TAG="del"
LOG="/home/$USER/.config/astroid/hooks/hook.log"
ID=$1
FILE=$(notmuch search --exclude=false --output=files id:"${ID}") # get actual file path of MID
if [[ $(notmuch search --exclude=false id:"${ID}" and tag:"${TAG}") ]]; then # only do something if mail is tagged "del"
rm ${FILE} # delete file
echo "[delmail] [SUCCESS] \"${FILE}\" tagged with \"${TAG}\" has been deleted. ID: ${ID}" >> $LOG
else
echo "[delmail] [ERROR] not tagged as \"${TAG}\" and therefore not deleted: ${ID}" >> $LOG
fi
sleep 5
2017-07-24 15:30:04 +02:00
notmuch new