Rspamd: Difference between revisions

imported>Onny
Add note on enable bayesian spam training
imported>Onny
Add tip on spam training
Line 67: Line 67:
systemd.services.rspamd.serviceConfig.SupplementaryGroups = [ "maddy" ];
systemd.services.rspamd.serviceConfig.SupplementaryGroups = [ "maddy" ];
</nowiki>}}
</nowiki>}}
== Tips and tricks ==
=== Helper script to train rspamd ===
{{note|This approach is not yet stable and will be available in the upcoming NixOS 24.05 release.}}
The following example enables [https://gitlab.com/onlime/rspamd-trainer rspamd-trainer] as a daemon which will run every 10 minutes to check for mails in the inbox of <code>myuser@example.com</code> which should be used for spam/ham training.
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
services.rspamd-trainer = {
  enable = true;
  settings = {
    HOST = "example.com";
    USERNAME = "myuser@example.com";
    INBOXPREFIX = "INBOX/";
  };
  secrets = [
    # Do not use this in production. This will make passwords
    # world-readable in the Nix store
    "${pkgs.writeText "secrets" ''
      PASSWORD = test123
    ''}"
  ];
};
</nowiki>}}
The script will look into <code>INBOX/report_ham</code> and <code>INBOX/report_spam</code> respectivley for mails which will be feed into rspamd for training. After that they get moved to <code>INBOX/learned_ham</code> and <code>INBOX/learned_spam</code>. The report directories have to be created before that. You can do this using openssl:
<syntaxhighlight lang="console">
# openssl s_client -connect example.com:993 -crlf
A login myuser@example.com test123
A create "INBOX/report_spam"
A create "INBOX/report_ham"
A create "INBOX/report_spam_reply"
</syntaxhighlight>


[[Category:Mail Server]]
[[Category:Mail Server]]