mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-07-13 10:54:58 +02:00
feat: Allow marking spam as read via a sieve filter (ENV MARK_SPAM_AS_READ=1
) (#3489)
* add MARK_SPAM_AS_READ environment variable * review changes Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com> * update unit test --------- Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
This commit is contained in:
parent
5bada0a83b
commit
bb2038e8c6
8 changed files with 70 additions and 0 deletions
|
@ -271,3 +271,28 @@ EOF
|
|||
_log 'debug' 'Spam emails will not be moved to the Junk folder'
|
||||
fi
|
||||
}
|
||||
|
||||
function _setup_spam_mark_as_read() {
|
||||
if [[ ${MARK_SPAM_AS_READ} -eq 1 ]]; then
|
||||
_log 'debug' 'Spam emails will be marked as read'
|
||||
mkdir -p /usr/lib/dovecot/sieve-global/after/
|
||||
|
||||
# Header support: `X-Spam-Flag` (SpamAssassin), `X-Spam` (Rspamd)
|
||||
cat >/usr/lib/dovecot/sieve-global/after/spam_mark_as_read.sieve << EOF
|
||||
require ["mailbox","imap4flags"];
|
||||
|
||||
if anyof (header :contains "X-Spam-Flag" "YES",
|
||||
header :contains "X-Spam" "Yes") {
|
||||
setflag "\\\\Seen";
|
||||
}
|
||||
EOF
|
||||
sievec /usr/lib/dovecot/sieve-global/after/spam_mark_as_read.sieve
|
||||
chown dovecot:root /usr/lib/dovecot/sieve-global/after/spam_mark_as_read.{sieve,svbin}
|
||||
|
||||
if [[ ${ENABLE_SPAMASSASSIN} -eq 1 ]] && [[ ${SPAMASSASSIN_SPAM_TO_INBOX} -eq 0 ]]; then
|
||||
_log 'warning' "'SPAMASSASSIN_SPAM_TO_INBOX=0' but it is required to be 1 for 'MARK_SPAM_AS_READ=1' to work"
|
||||
fi
|
||||
else
|
||||
_log 'debug' 'Spam emails will not be marked as read'
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ function __environment_variables_general_setup() {
|
|||
VARS[CLAMAV_MESSAGE_SIZE_LIMIT]="${CLAMAV_MESSAGE_SIZE_LIMIT:=25M}"
|
||||
VARS[FAIL2BAN_BLOCKTYPE]="${FAIL2BAN_BLOCKTYPE:=drop}"
|
||||
VARS[MOVE_SPAM_TO_JUNK]="${MOVE_SPAM_TO_JUNK:=1}"
|
||||
VARS[MARK_SPAM_AS_READ]="${MARK_SPAM_AS_READ:=0}"
|
||||
VARS[POSTGREY_AUTO_WHITELIST_CLIENTS]="${POSTGREY_AUTO_WHITELIST_CLIENTS:=5}"
|
||||
VARS[POSTGREY_DELAY]="${POSTGREY_DELAY:=300}"
|
||||
VARS[POSTGREY_MAX_AGE]="${POSTGREY_MAX_AGE:=35}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue