mirror of
https://git.myvelabs.com/docker/myvemail.git
synced 2025-12-17 19:46:19 +00:00
Add environment option to filter rejected emails
This commit is contained in:
parent
4b374113ce
commit
acc168d13e
2 changed files with 19 additions and 6 deletions
3
.env
3
.env
|
|
@ -31,6 +31,9 @@ MYVEMAIL_BLACKLIST_DOMAINS=
|
|||
# Blacklist invididual email addresses (eg. email@website.tld,email2@website2.tld2)
|
||||
MYVEMAIL_BLACKLIST_EMAILS=
|
||||
|
||||
# Filter rejected email updates from a pattern separated by commas
|
||||
MYVEMAIL_REJECT_FILTER=
|
||||
|
||||
# Volumes
|
||||
MYVEMAIL_VOLUME_MARIADB=
|
||||
MYVEMAIL_VOLUME_SSL=
|
||||
|
|
|
|||
|
|
@ -1,14 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
# Check filters
|
||||
unset filters
|
||||
if [ ${MYVEMAIL_REJECT_FILTER} ]
|
||||
then
|
||||
filters+=(${MYVEMAIL_REJECT_FILTER//,/ })
|
||||
fi
|
||||
|
||||
# Notify if rejected emails were found
|
||||
while true
|
||||
do
|
||||
bash -c 'tail -n +0 --pid=$$ -f /var/log/mail/maillog.debug* | grep --line-buffered -F -v -f /var/log/mail/reject.log | { sed "/NOQUEUE: reject/q" && kill $$ ;}'
|
||||
grep -h "NOQUEUE: reject" /var/log/mail/maillog.debug* | grep -F -v -f /var/log/mail/reject.log >>/var/log/mail/reject.log
|
||||
cat <<- mail | sendmail reject@${MYVEMAIL_DOMAIN}
|
||||
From: reject@${MYVEMAIL_DOMAIN}
|
||||
To: reject@${MYVEMAIL_DOMAIN}
|
||||
Subject: Rejected email found
|
||||
if ! tail -n 1 /var/log/mail/reject.log | grep -i -q "$(printf '%s\|' ${filters[@]:-impossible-string-that-would-never-be-grepped} | sed 's|\\\|$||')"
|
||||
then
|
||||
cat <<- mail | sendmail reject@${MYVEMAIL_DOMAIN}
|
||||
From: reject@${MYVEMAIL_DOMAIN}
|
||||
To: reject@${MYVEMAIL_DOMAIN}
|
||||
Subject: Rejected email found
|
||||
|
||||
$(tail -n 1 /var/log/mail/reject.log)
|
||||
mail
|
||||
$(tail -n 1 /var/log/mail/reject.log)
|
||||
mail
|
||||
fi
|
||||
done >/dev/null &
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue