feat: this should put an automatic bcc on outgoing mail as well as a corrosponding filter to put it in teh right inboxes
Relates to #84
This commit is contained in:
parent
1212ecc7a1
commit
35920eda0c
1 changed files with 48 additions and 0 deletions
|
@ -114,6 +114,21 @@ with lib; let
|
|||
stop;
|
||||
} else {
|
||||
fileinto :create "''${1}";
|
||||
stop;
|
||||
}
|
||||
}
|
||||
}
|
||||
if allof (
|
||||
address :localpart ["From"] ["${toString create_config_to}"],
|
||||
address :domain ["From"] "skynet.ie"
|
||||
){
|
||||
if address :matches ["From"] "*@skynet.ie" {
|
||||
if header :is "X-Spam" "Yes" {
|
||||
fileinto :create "''${1}.Junk";
|
||||
stop;
|
||||
} else {
|
||||
fileinto :create "''${1}";
|
||||
stop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -465,6 +480,39 @@ in {
|
|||
before = configFile;
|
||||
};
|
||||
|
||||
# This is to add a bcc to outgoing mail
|
||||
# this then interacts with teh filters to put it in the right folder
|
||||
# we can directly add to the postfix service here
|
||||
services.postfix = let
|
||||
# mostly copied from the upstream mailserver config/functions
|
||||
mappedFile = name: "hash:/var/lib/postfix/conf/${name}";
|
||||
|
||||
sender_bcc_maps_file = let
|
||||
content = lookupTableToString create_skynet_service_bcc;
|
||||
in
|
||||
builtins.toFile "sender_bcc_maps" content;
|
||||
|
||||
lookupTableToString = attrs: let
|
||||
valueToString = value: lib.concatStringsSep ", " value;
|
||||
in
|
||||
lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value: "${name} ${valueToString value}") attrs);
|
||||
|
||||
# convert the mailboxes config to something that can be used here
|
||||
create_skynet_email_bcc = mailbox: {
|
||||
name = "${mailbox}@skynet.ie";
|
||||
value = ["${mailbox}@skynet.ie"];
|
||||
};
|
||||
create_skynet_service_bcc = builtins.listToAttrs (map (mailbox: (create_skynet_email_bcc mailbox.account)) service_mailboxes);
|
||||
in {
|
||||
mapFiles."sender_bcc_maps" = sender_bcc_maps_file;
|
||||
|
||||
config = {
|
||||
sender_bcc_maps = [
|
||||
(mappedFile "sender_bcc_maps")
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
# tune the spam filter
|
||||
/*
|
||||
services.rspamd.extraConfig = ''
|
||||
|
|
Loading…
Reference in a new issue