Implement basic sieve support using Dovecot.

The dovecot-sieve plugin is installed and configured to apply sieve
as soon as a .dovecot.sieve file is encountered in the virtual user's
home directory (that is /var/mail/${domain}/${username}/.dovecot.sieve).

Transport has been changed in the postfix configuration to use
Dovecot LDA (see http://wiki.dovecot.org/LDA/Postfix) to actually
enable sieve filtering.

Tests have been added.
This commit is contained in:
André Stein 2016-04-28 08:57:50 +02:00
parent 1a77cb77cc
commit 2f9f6b1002
8 changed files with 49 additions and 4 deletions

View file

@ -0,0 +1,8 @@
require ["fileinto", "reject"];
if address :contains ["From"] "spam@spam.com" {
fileinto "INBOX.spam";
} else {
keep;
}

View file

@ -0,0 +1,12 @@
HELO mail.external.tld
MAIL FROM: user@external.tld
RCPT TO: user1@localhost.localdomain
DATA
From: Spambot <spam@spam.com>
To: Existing Local User <alias2@localhost.localdomain>
Date: Sat, 22 May 2010 07:43:25 -0400
Subject: Test Message
This is a test mail.
.
QUIT

View file

@ -129,9 +129,9 @@
}
@test "checking smtp: delivers mail to existing account" {
run docker exec mail /bin/sh -c "grep 'status=sent (delivered to maildir)' /var/log/mail/mail.log | wc -l"
run docker exec mail /bin/sh -c "grep 'status=sent (delivered via dovecot service)' /var/log/mail/mail.log | wc -l"
[ "$status" -eq 0 ]
[ "$output" -eq 2 ]
[ "$output" -eq 3 ]
}
@test "checking smtp: delivers mail to existing alias" {
@ -409,3 +409,13 @@
[ "$status" -eq 0 ]
[ "$output" = "my-domain.com" ]
}
#
# sieve
#
@test "checking sieve: user1 should have received 1 in folder INBOX.spam" {
run docker exec mail /bin/sh -c "ls -A /var/mail/localhost.localdomain/user1/.INBOX.spam/new | wc -l"
[ "$status" -eq 0 ]
[ "$output" = 1 ]
}