mirror of
https://gitlab.com/simple-nixos-mailserver/nixos-mailserver.git
synced 2024-12-28 16:06:12 +01:00
commit
58896e39ec
5 changed files with 31 additions and 7 deletions
|
@ -54,6 +54,7 @@ the user accounts.
|
||||||
* Sieves
|
* Sieves
|
||||||
- [x] A simple standard script that moves spam
|
- [x] A simple standard script that moves spam
|
||||||
- [x] Allow user defined sieve scripts
|
- [x] Allow user defined sieve scripts
|
||||||
|
- [x] ManageSieve support
|
||||||
* User Aliases
|
* User Aliases
|
||||||
- [x] Regular aliases
|
- [x] Regular aliases
|
||||||
- [x] Catch all aliases
|
- [x] Catch all aliases
|
||||||
|
@ -179,6 +180,9 @@ common ones.
|
||||||
enableImapSsl = true;
|
enableImapSsl = true;
|
||||||
enablePop3Ssl = true;
|
enablePop3Ssl = true;
|
||||||
|
|
||||||
|
# Enable the ManageSieve protocol
|
||||||
|
enableManageSieve = true;
|
||||||
|
|
||||||
# whether to scan inbound emails for viruses (note that this requires at least
|
# whether to scan inbound emails for viruses (note that this requires at least
|
||||||
# 1 Gb RAM for the server. Without virus scanning 256 MB RAM should be plenty)
|
# 1 Gb RAM for the server. Without virus scanning 256 MB RAM should be plenty)
|
||||||
virusScanning = false;
|
virusScanning = false;
|
||||||
|
|
12
default.nix
12
default.nix
|
@ -280,6 +280,18 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enableManageSieve = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Whether to enable ManageSieve, setting this option to true will open
|
||||||
|
port 4190 in the firewall.
|
||||||
|
|
||||||
|
The ManageSieve protocol allows users to manage their Sieve scripts on
|
||||||
|
a remote server with a supported client, including Thunderbird.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
virusScanning = mkOption {
|
virusScanning = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
|
|
@ -41,7 +41,7 @@ in
|
||||||
protocols = [ "sieve" ];
|
protocols = [ "sieve" ];
|
||||||
|
|
||||||
sieveScripts = {
|
sieveScripts = {
|
||||||
before = builtins.toFile "spam.sieve" ''
|
after = builtins.toFile "spam.sieve" ''
|
||||||
require "fileinto";
|
require "fileinto";
|
||||||
|
|
||||||
if header :is "X-Spam" "Yes" {
|
if header :is "X-Spam" "Yes" {
|
||||||
|
@ -109,7 +109,9 @@ in
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin {
|
plugin {
|
||||||
sieve = file:/var/sieve/%u.sieve
|
sieve = file:/var/sieve/%u/scripts;active=/var/sieve/%u/active.sieve
|
||||||
|
sieve_default = file:/var/sieve/%u/default.sieve
|
||||||
|
sieve_default_name = default
|
||||||
}
|
}
|
||||||
|
|
||||||
lda_mailbox_autosubscribe = yes
|
lda_mailbox_autosubscribe = yes
|
||||||
|
|
|
@ -28,6 +28,7 @@ in
|
||||||
++ lib.optional enableImapSsl 993
|
++ lib.optional enableImapSsl 993
|
||||||
++ lib.optional enablePop3 110
|
++ lib.optional enablePop3 110
|
||||||
++ lib.optional enablePop3Ssl 995
|
++ lib.optional enablePop3Ssl 995
|
||||||
|
++ lib.optional enableManageSieve 4190
|
||||||
++ lib.optional (certificateScheme == 3) 80;
|
++ lib.optional (certificateScheme == 3) 80;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,16 +55,21 @@ let
|
||||||
# is null, remove the file.
|
# is null, remove the file.
|
||||||
${lib.concatMapStringsSep "\n" ({ name, sieveScript }:
|
${lib.concatMapStringsSep "\n" ({ name, sieveScript }:
|
||||||
if lib.isString sieveScript then ''
|
if lib.isString sieveScript then ''
|
||||||
cat << EOF > "/var/sieve/${name}.sieve"
|
if (! test -d "/var/sieve/${name}"); then
|
||||||
|
mkdir -p "/var/sieve/${name}"
|
||||||
|
chown "${name}:${vmailGroupName}" "/var/sieve/${name}"
|
||||||
|
chmod 770 "/var/sieve/${name}"
|
||||||
|
fi
|
||||||
|
cat << EOF > "/var/sieve/${name}/default.sieve"
|
||||||
${sieveScript}
|
${sieveScript}
|
||||||
EOF
|
EOF
|
||||||
chown "${name}:${vmailGroupName}" "/var/sieve/${name}.sieve"
|
chown "${name}:${vmailGroupName}" "/var/sieve/${name}/default.sieve"
|
||||||
'' else ''
|
'' else ''
|
||||||
if (test -f "/var/sieve/${name}.sieve"); then
|
if (test -f "/var/sieve/${name}/default.sieve"); then
|
||||||
rm "/var/sieve/${name}.sieve"
|
rm "/var/sieve/${name}/default.sieve"
|
||||||
fi
|
fi
|
||||||
if (test -f "/var/sieve/${name}.svbin"); then
|
if (test -f "/var/sieve/${name}.svbin"); then
|
||||||
rm "/var/sieve/${name}.svbin"
|
rm "/var/sieve/${name}/default.svbin"
|
||||||
fi
|
fi
|
||||||
'') (map (user: { inherit (user) name sieveScript; })
|
'') (map (user: { inherit (user) name sieveScript; })
|
||||||
(lib.attrValues loginAccounts))}
|
(lib.attrValues loginAccounts))}
|
||||||
|
|
Loading…
Reference in a new issue