Moved email rejects to its own file

This commit is contained in:
myve 2025-02-26 13:44:55 +00:00
commit 008d6ac4ad
2 changed files with 20 additions and 15 deletions

View file

@ -0,0 +1,20 @@
#!/usr/bin/env bash
# Notify if rejected emails were found
function monitor-rejects
{
while true
do
bash -c 'tail -n +0 --pid=$$ -f /var/log/mail/maillog* | grep --line-buffered -F -v -f /var/log/mail/reject.log | { sed "/NOQUEUE: reject/q" && kill $$ ;}'
local reject="$(grep "NOQUEUE: reject" /var/log/mail/maillog* | grep -F -v -f /var/log/mail/reject.log)"
echo ${reject} >>/var/log/mail/reject.log
cat <<- mail | sendmail reject@${MYVEMAIL_DOMAIN}
From: reject@${MYVEMAIL_DOMAIN}
To: reject@${MYVEMAIL_DOMAIN}
Subject: Rejected email found
${reject}
mail
done
}
monitor-rejects &