mirror of
https://git.sr.ht/~rouven/nixos-config
synced 2025-01-19 01:21:39 +01:00
mail: use nix native sieve options
This commit is contained in:
parent
71939c6c39
commit
82aa8774d9
3 changed files with 33 additions and 48 deletions
|
@ -1,4 +1,4 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
domain = config.networking.domain;
|
domain = config.networking.domain;
|
||||||
|
@ -28,34 +28,6 @@ in
|
||||||
description = "Rouven Seifert";
|
description = "Rouven Seifert";
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
};
|
};
|
||||||
environment.etc = {
|
|
||||||
"dovecot/sieve-pipe/sa-learn-spam.sh" = {
|
|
||||||
text = ''
|
|
||||||
#!/bin/sh
|
|
||||||
${pkgs.rspamd}/bin/rspamc learn_spam
|
|
||||||
'';
|
|
||||||
mode = "0555";
|
|
||||||
};
|
|
||||||
"dovecot/sieve-pipe/sa-learn-ham.sh" = {
|
|
||||||
text = ''
|
|
||||||
#!/bin/sh
|
|
||||||
${pkgs.rspamd}/bin/rspamc learn_ham
|
|
||||||
'';
|
|
||||||
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 = {
|
||||||
postfix = {
|
postfix = {
|
||||||
|
@ -153,6 +125,36 @@ in
|
||||||
modules = [
|
modules = [
|
||||||
pkgs.dovecot_pigeonhole
|
pkgs.dovecot_pigeonhole
|
||||||
];
|
];
|
||||||
|
sieve = {
|
||||||
|
# just pot something in here to prevent empty strings
|
||||||
|
extensions = [ "notify" ];
|
||||||
|
# globalExtensions = [ "+vnd.dovecot.pipe" ];
|
||||||
|
pipeBins = map lib.getExe [
|
||||||
|
(pkgs.writeShellScriptBin "learn-ham.sh" "exec ${pkgs.rspamd}/bin/rspamc learn_ham")
|
||||||
|
(pkgs.writeShellScriptBin "learn-spam.sh" "exec ${pkgs.rspamd}/bin/rspamc learn_spam")
|
||||||
|
];
|
||||||
|
plugins = [
|
||||||
|
"sieve_imapsieve"
|
||||||
|
"sieve_extprograms"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
imapsieve.mailbox = [
|
||||||
|
{
|
||||||
|
# Spam: From elsewhere to Spam folder or flag changed in Spam folder
|
||||||
|
name = "Spam";
|
||||||
|
causes = [ "COPY" "APPEND" "FLAG" ];
|
||||||
|
before = ./report-spam.sieve;
|
||||||
|
|
||||||
|
}
|
||||||
|
{
|
||||||
|
# From Junk folder to elsewhere
|
||||||
|
name = "*";
|
||||||
|
from = "Spam";
|
||||||
|
causes = [ "COPY" ];
|
||||||
|
before = ./report-ham.sieve;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
auth_username_format = %Ln
|
auth_username_format = %Ln
|
||||||
userdb {
|
userdb {
|
||||||
|
@ -185,23 +187,6 @@ in
|
||||||
}
|
}
|
||||||
client_limit = 1
|
client_limit = 1
|
||||||
}
|
}
|
||||||
plugin {
|
|
||||||
sieve_plugins = sieve_imapsieve sieve_extprograms
|
|
||||||
sieve_global_extensions = +vnd.dovecot.pipe
|
|
||||||
sieve_pipe_bin_dir = /etc/dovecot/sieve-pipe
|
|
||||||
|
|
||||||
# Spam: From elsewhere to Spam folder or flag changed in Spam folder
|
|
||||||
imapsieve_mailbox1_name = Spam
|
|
||||||
imapsieve_mailbox1_causes = COPY APPEND FLAG
|
|
||||||
imapsieve_mailbox1_before = file:/etc/dovecot/sieve/report-spam.sieve
|
|
||||||
|
|
||||||
# From Junk folder to elsewhere
|
|
||||||
imapsieve_mailbox2_name = *
|
|
||||||
imapsieve_mailbox2_from = Spam
|
|
||||||
imapsieve_mailbox2_causes = COPY
|
|
||||||
imapsieve_mailbox2_before = file:/etc/dovecot/sieve/report-ham.sieve
|
|
||||||
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,4 @@ if environment :matches "imap.user" "*" {
|
||||||
set "username" "${1}";
|
set "username" "${1}";
|
||||||
}
|
}
|
||||||
|
|
||||||
pipe :copy "sa-learn-ham.sh" [ "${username}" ];
|
pipe :copy "learn-ham.sh" [ "${username}" ];
|
||||||
|
|
|
@ -4,4 +4,4 @@ if environment :matches "imap.user" "*" {
|
||||||
set "username" "${1}";
|
set "username" "${1}";
|
||||||
}
|
}
|
||||||
|
|
||||||
pipe :copy "sa-learn-spam.sh" [ "${username}" ];
|
pipe :copy "learn-spam.sh" [ "${username}" ];
|
||||||
|
|
Loading…
Reference in a new issue