mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-03 09:34:33 +02:00
init spams to junk
This commit is contained in:
parent
7eacb4cfc0
commit
d829905cf7
7 changed files with 126 additions and 13 deletions
|
@ -3,7 +3,8 @@ use strict;
|
|||
# Override options set in earlier files, use 50-user to override these
|
||||
|
||||
# Bounce spam, the default option for buster is D_PASS to deliver
|
||||
$final_spam_destiny = D_BOUNCE;
|
||||
$final_spam_destiny = D_BOUNCE;
|
||||
$final_bad_header_destiny = D_BOUNCE;
|
||||
|
||||
# Higher log level to get expected messages at startup
|
||||
$log_level = 2;
|
||||
|
|
|
@ -32,7 +32,7 @@ plugin {
|
|||
# file names, using a normal 8bit per-character comparison. Multiple script
|
||||
# file or directory paths can be specified by appending an increasing number.
|
||||
#sieve_before = /usr/lib/dovecot/sieve-global/before.dovecot.sieve
|
||||
#sieve_before2 =
|
||||
#sieve_before2 = /usr/lib/dovecot/sieve-global/before.spam.sieve
|
||||
#sieve_before3 = (etc...)
|
||||
|
||||
# Identical to sieve_before, only the specified scripts are executed after the
|
||||
|
|
4
target/dovecot/sieve/before.spam.sieve
Normal file
4
target/dovecot/sieve/before.spam.sieve
Normal file
|
@ -0,0 +1,4 @@
|
|||
require "fileinto";
|
||||
if header :contains "X-Spam-Flag" "YES" {
|
||||
fileinto "Junk";
|
||||
}
|
|
@ -40,6 +40,7 @@ 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["MOVE_SPAM_TO_JUNK"]="${MOVE_SPAM_TO_JUNK:="1"}"
|
||||
DEFAULT_VARS["VIRUSMAILS_DELETE_DELAY"]="${VIRUSMAILS_DELETE_DELAY:="7"}"
|
||||
|
||||
##########################################################################
|
||||
|
@ -627,6 +628,16 @@ function _setup_dovecot() {
|
|||
else
|
||||
sed -i "s/ sieve_after =/ #sieve_after =/" /etc/dovecot/conf.d/90-sieve.conf
|
||||
fi
|
||||
|
||||
# sieve will move spams to .Junk folder when SPAMASSASSIN_SPAM_TO_INBOX=1 and MOVE_SPAM_TO_JUNK=1
|
||||
if [ "$SPAMASSASSIN_SPAM_TO_INBOX" = 1 ] && [ "$MOVE_SPAM_TO_JUNK" = 1 ]; then
|
||||
notify 'inf' "Spam messages will be moved to the Junk folder."
|
||||
sed -i "s/#sieve_before2 =/sieve_before2 =/" /etc/dovecot/conf.d/90-sieve.conf
|
||||
sievec /usr/lib/dovecot/sieve-global/before.spam.sieve
|
||||
else
|
||||
sed -i "s/ sieve_before2 =/ #sieve_before2 =/" /etc/dovecot/conf.d/90-sieve.conf
|
||||
fi
|
||||
|
||||
chown docker:docker -R /usr/lib/dovecot/sieve*
|
||||
chmod 550 -R /usr/lib/dovecot/sieve*
|
||||
chmod -f +x /usr/lib/dovecot/sieve-pipe/*
|
||||
|
@ -1475,19 +1486,15 @@ function _setup_security_stack() {
|
|||
test -e /tmp/docker-mailserver/spamassassin-rules.cf && cp /tmp/docker-mailserver/spamassassin-rules.cf /etc/spamassassin/
|
||||
|
||||
|
||||
if [ "$SPAMASSASSIN_SPAM_TO_INBOX" = "1" ]; then
|
||||
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
|
||||
sed -i "s/\$final_spam_destiny.*=.*$/\$final_spam_destiny = D_PASS;/g" /etc/amavis/conf.d/49-docker-mailserver
|
||||
sed -i "s/\$final_bad_header_destiny.*=.*$/\$final_bad_header_destiny = D_PASS;/g" /etc/amavis/conf.d/49-docker-mailserver
|
||||
else
|
||||
notify 'warn' "Spam messages WILL NOT BE DELIVERED, you will NOT be notified of ANY message bounced. See SPAMASSASSIN_SPAM_TO_INBOX options."
|
||||
sed -i "s/\$final_spam_destiny.*=.*$/\$final_spam_destiny = D_BOUNCE;/g" /etc/amavis/conf.d/49-docker-mailserver
|
||||
sed -i "s/\$final_bad_header_destiny.*=.*$/\$final_bad_header_destiny = D_BOUNCE;/g" /etc/amavis/conf.d/49-docker-mailserver
|
||||
fi
|
||||
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue