Last active
May 25, 2021 08:11
-
-
Save hsntgm/62321c86a04421d4241551cb8e7817a9 to your computer and use it in GitHub Desktop.
Dovecot -- find and delete mails that sent by mistake if unseen yet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# >> LDA-Dovecot << | |
# Find and delete mails which accidently sent to wrong mailbox if unseen yet. | |
# Works very fast in big mailboxes. Search for uniq_word in body. | |
mbox="INBOX" | |
mailbox="[email protected]" | |
date="2021-05-14" | |
str="uniq_word" | |
if ! [[ -z $(doveadm search -u $mailbox SAVEDON $date BODY "$str" \( NEW \)) ]]; then | |
echo "Your lucky day dear Admin! Bomb defused.." | |
doveadm expunge -u $mailbox mailbox "$mbox" SAVEDON $date BODY "$str" \( NEW \) | |
else | |
echo "No matter what happens dear Admin.Take a coffe!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment