From d148eeddfb1d7025a2035a9a3a063b0ca2dc6c11 Mon Sep 17 00:00:00 2001 From: Wandrille RONCE Date: Sun, 15 Mar 2020 17:51:12 +0100 Subject: [PATCH] Add an option to place spam in the inbox, and then sort the mail by a sieve rule for example --- env-mailserver.dist | 3 +++ target/start-mailserver.sh | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/env-mailserver.dist b/env-mailserver.dist index 86b8b3cf..90e3372b 100644 --- a/env-mailserver.dist +++ b/env-mailserver.dist @@ -136,6 +136,9 @@ REPORT_INTERVAL=daily ENABLE_SPAMASSASSIN=0 +#If Enabled, SPAM goes to your inbox with added SPAM header, you can then move it to a specific SPAM folder with SIEVE rules +SPAMASSASSIN_SPAM_TO_INBOX=0 + # add spam info headers if at, or above that level: SA_TAG=2.0 diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index cb3212b2..5b3c04b7 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -37,6 +37,7 @@ DEFAULT_VARS["SRS_SENDER_CLASSES"]="${SRS_SENDER_CLASSES:="envelope_sender"}" DEFAULT_VARS["REPORT_RECIPIENT"]="${REPORT_RECIPIENT:="0"}" DEFAULT_VARS["LOGROTATE_INTERVAL"]="${LOGROTATE_INTERVAL:=${REPORT_INTERVAL:-"daily"}}" DEFAULT_VARS["LOGWATCH_INTERVAL"]="${LOGWATCH_INTERVAL:="none"}" +DEFAULT_VARS["SPAMASSASSIN_SPAM_TO_INBOX"]="${SPAMASSASSIN_SPAM_TO_INBOX:="0"}" DEFAULT_VARS["VIRUSMAILS_DELETE_DELAY"]="${VIRUSMAILS_DELETE_DELAY:="7"}" ########################################################################## @@ -1402,6 +1403,23 @@ function _setup_security_stack() { fi test -e /tmp/docker-mailserver/spamassassin-rules.cf && cp /tmp/docker-mailserver/spamassassin-rules.cf /etc/spamassassin/ + + + if [ "$SPAMASSASSIN_SPAM_TO_INBOX" = "1" ]; then + notify 'inf' "Configure Spamassassin/Amavis to put SPAM inbox" + bannedbouncecheck=`egrep "final_banned_destiny.*D_BOUNCE" /etc/amavis/conf.d/20-debian_defaults` + if [ -n "$bannedbouncecheck" ] ; + then + sed -i "/final_banned_destiny/ s|D_BOUNCE|D_REJECT|" /etc/amavis/conf.d/20-debian_defaults + fi + + finalbouncecheck=`egrep "final_spam_destiny.*D_BOUNCE" /etc/amavis/conf.d/20-debian_defaults` + if [ -n "$finalbouncecheck" ] ; + then + sed -i "/final_spam_destiny/ s|D_BOUNCE|D_PASS|" /etc/amavis/conf.d/20-debian_defaults + fi + fi + fi # Clamav