From 5a86193dbffefc253d9cbae040dc08927ddaa612 Mon Sep 17 00:00:00 2001 From: Alexander Elbracht Date: Fri, 23 Jun 2017 21:50:01 +0200 Subject: [PATCH] Environment variable for amavis subject tag (#596) * Environment variable for spam subject tag * Add SA_SPAM_SUBJECT to readme * Add integration tests for spam subject tag * Fix overwrite environment variable in config file --- Makefile | 1 + README.md | 7 ++++++- target/start-mailserver.sh | 1 + test/tests.bats | 4 ++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d8a99868..c43fd70b 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,7 @@ run: -e SA_TAG=-5.0 \ -e SA_TAG2=2.0 \ -e SA_KILL=3.0 \ + -e SA_SPAM_SUBJECT="SPAM: " \ -e VIRUSMAILS_DELETE_DELAY=7 \ -e SASL_PASSWD="external-domain.com username:password" \ -e ENABLE_MANAGESIEVE=1 \ diff --git a/README.md b/README.md index 22e981ea..438af213 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,12 @@ Note: this spamassassin setting needs `ENABLE_SPAMASSASSIN=1` Note: this spamassassin setting needs `ENABLE_SPAMASSASSIN=1` +##### SA_SPAM_SUBJECT + + - **\*\*\*SPAM\*\*\*** => add tag to subject if spam detected + +Note: this spamassassin setting needs `ENABLE_SPAMASSASSIN=1` + ##### ONE_DIR - **0** => state in default directories @@ -336,4 +342,3 @@ Enabled by ENABLE_POSTFIX_VIRTUAL_TRANSPORT. Specify the final delivery of postf - lmtps:inet:: (secure lmtp with starttls, take a look at https://sys4.de/en/blog/2014/11/17/sicheres-lmtp-mit-starttls-in-dovecot/) - lmtp::2003 (use kopano as mailstore) - etc. - diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index a2a6b5de..56a7ac6c 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -970,6 +970,7 @@ function _setup_security_stack() { SA_TAG=${SA_TAG:="2.0"} && sed -i -r 's/^\$sa_tag_level_deflt (.*);/\$sa_tag_level_deflt = '$SA_TAG';/g' /etc/amavis/conf.d/20-debian_defaults SA_TAG2=${SA_TAG2:="6.31"} && sed -i -r 's/^\$sa_tag2_level_deflt (.*);/\$sa_tag2_level_deflt = '$SA_TAG2';/g' /etc/amavis/conf.d/20-debian_defaults SA_KILL=${SA_KILL:="6.31"} && sed -i -r 's/^\$sa_kill_level_deflt (.*);/\$sa_kill_level_deflt = '$SA_KILL';/g' /etc/amavis/conf.d/20-debian_defaults + SA_SPAM_SUBJECT=${SA_SPAM_SUBJECT:="***SPAM*** "} && sed -i -r 's/^\$sa_spam_subject_tag (.*);/\$sa_spam_subject_tag = '"'$SA_SPAM_SUBJECT'"';/g' /etc/amavis/conf.d/20-debian_defaults test -e /tmp/docker-mailserver/spamassassin-rules.cf && cp /tmp/docker-mailserver/spamassassin-rules.cf /etc/spamassassin/ fi diff --git a/test/tests.bats b/test/tests.bats index 512aee35..c27872b0 100644 --- a/test/tests.bats +++ b/test/tests.bats @@ -429,6 +429,8 @@ load 'test_helper/bats-assert/load' assert_success run docker exec mail_pop3 /bin/sh -c "grep '\$sa_kill_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 6.31'" assert_success + run docker exec mail_pop3 /bin/sh -c "grep '\$sa_spam_subject_tag' /etc/amavis/conf.d/20-debian_defaults | grep '= .\*\*\*SPAM\*\*\* .'" + assert_success } @test "checking spamassassin: docker env variables are set correctly (custom)" { @@ -438,6 +440,8 @@ load 'test_helper/bats-assert/load' assert_success run docker exec mail /bin/sh -c "grep '\$sa_kill_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 3.0'" assert_success + run docker exec mail /bin/sh -c "grep '\$sa_spam_subject_tag' /etc/amavis/conf.d/20-debian_defaults | grep '= .SPAM: .'" + assert_success } @test "checking spamassassin: all registered domains should see spam headers" {