Rspamd Bayes
Zur Navigation springen
Zur Suche springen
Bayes ON TOP des bestehenden Keyword-Setups
Ziel
- Keyword-Filter bleibt aktiv
- Bayes wird zusätzlich aktiviert
- KEIN Reject
- KEIN Greylist
- KEIN Autolearn
- Lernen nur manuell
- Junk-Logik bleibt ausschließlich in Dovecot/Sieve
Voraussetzung
- Dein bestehendes Setup funktioniert
- rspamd setzt X-Spam
- Yes
- Dovecot sortiert nach Junk
Schritt 1: Bayes aktivieren (kontrolliert)
- vi /etc/rspamd/local.d/classifier-bayes.conf
backend = "sqlite3";
autolearn = false;
min_tokens = 11;
statfile {
name = "bayes_spam";
symbol = "BAYES_SPAM";
path = "/var/lib/rspamd/bayes_spam.sqlite";
}
statfile {
name = "bayes_ham";
symbol = "BAYES_HAM";
path = "/var/lib/rspamd/bayes_ham.sqlite";
}
- systemctl restart rspamd
Schritt 2: Prüfen, ob Bayes geladen ist
- rspamadm configtest
syntax OK
Schritt 3: Bayes-Status prüfen (leer ist OK)
- rspamc stat
- Erwartung
- Bayes statistics
- learned
- 0 spam, 0 ham
Schritt 4: Erste Trainingsmails vorbereiten
- Hinweis
- Die folgenden Beispiele sind Trainingsmails für Bayes.
- In der Praxis müssen die Dateien OHNE führende Leerzeichen erstellt werden.
- Die Einrückung dient ausschließlich der MediaWiki-Darstellung.
- Spam-Beispiel (nur als Formatbeispiel – nicht ideal für Bayes, da Keyword-basiert)
- vi /root/spam1.eml
From: offer@newsletter.example To: user@example.de Subject: limited time special offer just for you Date: Sun, 14 Dec 2025 19:00:00 +0100 Message-ID: <spam1@bad.example> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 this is a limited time promotional offer exclusive discount available only today no prescription required fast approval order online with instant confirmation secure payment and fast worldwide delivery customer satisfaction guaranteed unsubscribe anytime using the link below
- vi /root/ham1.eml
From: colleague@good.example To: user@example.de Subject: project meeting agenda Date: Sun, 14 Dec 2025 19:01:00 +0100 Message-ID: <ham1@good.example> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 hello thomas, attached is the agenda for our project meeting next week. please review the topics in advance and let me know if something is missing. attached is the agenda for our project meeting next week. please review the topics in advance and let me know if something is missing. best regards
Schritt 5: Manuelles Lernen
- rspamc learn_spam /root/spam1.eml
- rspamc learn_ham /root/ham1.eml
Schritt 6: Lernstand prüfen
- rspamc stat
- Erwartung
- learned
- 1 spam, 1 ham
Schritt 7: Wirkung testen (ohne Keyword-Treffer)
- cat <<EOF | rspamc
From: x@y To: z@a Subject: cheap pills
buy pills online EOF
- Erwartung
- Symbol
- BAYES_SPAM oder BAYES_HAM
- Score > 0 (klein!)
Schritt 8: Zusammenspiel mit Keywords (realer Effekt)
- Beispiel
- CUSTOM_KEYWORDS +8.0
- BAYES_SPAM +2.x
- ---------------------
- Gesamt > add_header
- → X-Spam
- Yes
- → Sieve → Junk
WICHTIG
- Bayes ist am Anfang schwach
- Erst ab ~500 Spam + ~500 Ham brauchbar
- Keywords bleiben Hauptfilter
Merksatz
- Keywords = deterministisch
- Bayes = statistisch
- Sieve = entscheidet