mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Merge pull request #80 from tomav/fix-spamassassin-default-config
Added Spamassassin configuration using ENV variables (see README)
This commit is contained in:
commit
10d04efece
19
Makefile
19
Makefile
|
@ -1,19 +1,30 @@
|
|||
NAME = tvial/docker-mailserver
|
||||
VERSION = $(TRAVIS_BUILD_ID)
|
||||
|
||||
all: build run fixtures tests clean
|
||||
all-no-build: run fixtures tests clean
|
||||
|
||||
build:
|
||||
docker build --no-cache -t $(NAME):$(VERSION) .
|
||||
docker build --no-cache -t $(NAME) .
|
||||
|
||||
run:
|
||||
# Copy test files
|
||||
cp test/accounts.cf postfix/
|
||||
cp test/virtual postfix/
|
||||
# Run containers
|
||||
docker run -d --name mail -v "`pwd`/postfix":/tmp/postfix -v "`pwd`/spamassassin":/tmp/spamassassin -v "`pwd`/test":/tmp/test -h mail.my-domain.com -t $(NAME):$(VERSION)
|
||||
docker run -d --name mail_pop3 -v "`pwd`/postfix":/tmp/postfix -v "`pwd`/spamassassin":/tmp/spamassassin -v "`pwd`/test":/tmp/test -e ENABLE_POP3=1 -h mail.my-domain.com -t $(NAME):$(VERSION)
|
||||
docker run -d --name mail \
|
||||
-v "`pwd`/postfix":/tmp/postfix \
|
||||
-v "`pwd`/spamassassin":/tmp/spamassassin \
|
||||
-v "`pwd`/test":/tmp/test \
|
||||
-e SA_TAG=1.0 \
|
||||
-e SA_TAG2=2.0 \
|
||||
-e SA_KILL=3.0 \
|
||||
-h mail.my-domain.com -t $(NAME)
|
||||
docker run -d --name mail_pop3 \
|
||||
-v "`pwd`/postfix":/tmp/postfix \
|
||||
-v "`pwd`/spamassassin":/tmp/spamassassin \
|
||||
-v "`pwd`/test":/tmp/test \
|
||||
-e ENABLE_POP3=1 \
|
||||
-h mail.my-domain.com -t $(NAME)
|
||||
# Wait for containers to fully start
|
||||
sleep 60
|
||||
|
||||
|
|
|
@ -88,6 +88,12 @@ Example:
|
|||
* ENABLE_POP3
|
||||
* *empty* (default) => POP3 service disabled
|
||||
* 1 => Enables POP3 service
|
||||
* SA_TAG
|
||||
* *2.0* (default) => add spam info headers if at, or above that level
|
||||
* SA_TAG2
|
||||
* *6.31* (default) => add 'spam detected' headers at that level
|
||||
* SA_KILL
|
||||
* *6.31* (default) => triggers spam evasive actions)
|
||||
|
||||
Please read [how the container starts](https://github.com/tomav/docker-mailserver/blob/master/start-mailserver.sh) to understand what's expected.
|
||||
|
||||
|
|
|
@ -182,13 +182,11 @@ echo "Creating /etc/mailname"
|
|||
echo $(hostname -d) > /etc/mailname
|
||||
|
||||
echo "Configuring Spamassassin"
|
||||
echo "required_hits 5.0" >> /etc/mail/spamassassin/local.cf
|
||||
echo "report_safe 0" >> /etc/mail/spamassassin/local.cf
|
||||
echo "required_score 5" >> /etc/mail/spamassassin/local.cf
|
||||
echo "rewrite_header Subject ***SPAM***" >> /etc/mail/spamassassin/local.cf
|
||||
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
|
||||
cp /tmp/spamassassin/rules.cf /etc/spamassassin/
|
||||
|
||||
|
||||
echo "Configuring fail2ban"
|
||||
# enable filters
|
||||
perl -i -0pe 's/(\[postfix\]\n\n).*\n/\1enabled = true\n/' /etc/fail2ban/jail.conf
|
||||
|
|
|
@ -68,6 +68,14 @@ assert_raises "docker exec mail grep ': error:' /var/log/mail.log" 1
|
|||
assert_raises "docker exec mail_pop3 grep 'non-null host address bits in' /var/log/mail.log" 1
|
||||
assert_raises "docker exec mail_pop3 grep ': error:' /var/log/mail.log" 1
|
||||
|
||||
# Testing Spamssassin config in Amavis
|
||||
assert_raises "docker exec mail_pop3 grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 2.0'" 0
|
||||
assert_raises "docker exec mail_pop3 grep '\$sa_tag2_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 6.31'" 0
|
||||
assert_raises "docker exec mail_pop3 grep '\$sa_kill_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 6.31'" 0
|
||||
assert_raises "docker exec mail grep '\$sa_tag_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 1.0'" 0
|
||||
assert_raises "docker exec mail grep '\$sa_tag2_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 2.0'" 0
|
||||
assert_raises "docker exec mail grep '\$sa_kill_level_deflt' /etc/amavis/conf.d/20-debian_defaults | grep '= 3.0'" 0
|
||||
|
||||
# Testing OpenDKIM
|
||||
assert "docker exec mail cat /etc/opendkim/KeyTable | wc -l" "2"
|
||||
assert "docker exec mail ls -l /etc/opendkim/keys/ | grep '^d' | wc -l" "2"
|
||||
|
|
Loading…
Reference in a new issue