mail: put spam sieve scripts into /etc

This commit is contained in:
Rouven Seifert 2023-09-04 13:10:01 +02:00
parent a0f78133f6
commit 11b0903535
Signed by: rouven.seifert
GPG key ID: B95E8FE6B11C4D09
3 changed files with 36 additions and 2 deletions

View file

@ -53,6 +53,18 @@ in
''; '';
mode = "0555"; mode = "0555";
}; };
"dovecot/sieve/report-spam.sieve" = {
source = ./report-spam.sieve;
user = "dovecot2";
group = "dovecot2";
mode = "0544";
};
"dovecot/sieve/report-ham.sieve" = {
source = ./report-ham.sieve;
user = "dovecot2";
group = "dovecot2";
mode = "0544";
};
}; };
services = { services = {
@ -229,13 +241,13 @@ in
# Spam: From elsewhere to Spam folder or flag changed in Spam folder # Spam: From elsewhere to Spam folder or flag changed in Spam folder
imapsieve_mailbox1_name = Spam imapsieve_mailbox1_name = Spam
imapsieve_mailbox1_causes = COPY APPEND FLAG imapsieve_mailbox1_causes = COPY APPEND FLAG
imapsieve_mailbox1_before = file:/var/lib/dovecot/imap_sieve/report-spam.sieve imapsieve_mailbox1_before = file:/etc/dovecot/sieve/report-spam.sieve
# Ham: From Spam folder to elsewhere # Ham: From Spam folder to elsewhere
imapsieve_mailbox2_name = * imapsieve_mailbox2_name = *
imapsieve_mailbox2_from = Spam imapsieve_mailbox2_from = Spam
imapsieve_mailbox2_causes = COPY imapsieve_mailbox2_causes = COPY
imapsieve_mailbox1_before = file:/var/lib/dovecot/imap_sieve/report-ham.sieve imapsieve_mailbox2_before = file:/etc/dovecot/sieve/report-ham.sieve
} }
''; '';
}; };

15
modules/mail/report-ham.sieve Executable file
View file

@ -0,0 +1,15 @@
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.mailbox" "*" {
set "mailbox" "${1}";
}
if string "${mailbox}" "Trash" {
stop;
}
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
pipe :copy "sa-learn-ham.sh" [ "${username}" ];

7
modules/mail/report-spam.sieve Executable file
View file

@ -0,0 +1,7 @@
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
pipe :copy "sa-learn-spam.sh" [ "${username}" ];