<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Abraxas &#187; dovecot-antispam</title>
	<atom:link href="http://www.effinger.org/blog/tag/dovecot-antispam/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.effinger.org/blog</link>
	<description>a personal knowledge base</description>
	<lastBuildDate>Mon, 23 Jan 2012 22:05:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Dovecot, Exim, OpenLDAP und getmail unter Ubuntu – (5) DSpam</title>
		<link>http://www.effinger.org/blog/2010/02/20/dovecot-exim-openldap-und-getmail-unter-ubuntu-%e2%80%93-5-dspam/</link>
		<comments>http://www.effinger.org/blog/2010/02/20/dovecot-exim-openldap-und-getmail-unter-ubuntu-%e2%80%93-5-dspam/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 20:20:28 +0000</pubDate>
		<dc:creator>Markus Effinger</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[dovecot]]></category>
		<category><![CDATA[dovecot-antispam]]></category>
		<category><![CDATA[DSPAM]]></category>
		<category><![CDATA[exim]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Sieve]]></category>

		<guid isPermaLink="false">http://www.effinger.org/blog/?p=914</guid>
		<description><![CDATA[<p>Es ist nun schon eine ganze Weile her seit ich zum letzten Mal über mein Mailserversetup geschrieben habe. In den letzten vier Blogartikeln wurde das Zusammenspiel der Grundkomponenten mit Dovecot, Exim, OpenLDAP und getmail konfiguriert. Jetzt geht es ans Feintuning &#8211; das Einrichten eines Spamfilters mit dspam und dovecot-antispam.</p> Weshalb dspam? <p>Warum dspam wird vielleicht [...]]]></description>
			<content:encoded><![CDATA[<p>Es ist nun schon eine ganze Weile her seit ich zum letzten Mal über mein Mailserversetup geschrieben habe. In den letzten vier Blogartikeln wurde das Zusammenspiel der Grundkomponenten mit <a href="http://www.effinger.org/blog/2009/03/22/dovecot-postfix-openldap-und-getmail-unter-ubuntu-2-dovecot/">Dovecot</a>, <a href="http://www.effinger.org/blog/2009/03/22/dovecot-exim-openldap-und-getmail-unter-ubuntu-3-exim/">Exim</a>, <a href="http://www.effinger.org/blog/2009/03/22/dovecot-exim-openldap-und-getmail-unter-ubuntu-1-openldap/">OpenLDAP</a> und <a href="http://www.effinger.org/blog/2009/03/22/dovecot-exim-openldap-und-getmail-unter-ubuntu-4-getmail/">getmail</a> konfiguriert. Jetzt geht es ans Feintuning &#8211; das Einrichten eines Spamfilters mit <a href="http://dspam.sourceforge.net/">dspam</a> und <a href="http://johannes.sipsolutions.net/Projects/dovecot-antispam">dovecot-antispam</a>.</p>
<h2>Weshalb dspam?</h2>
<p>Warum dspam wird vielleicht manch einer fragen und nicht das weitverbreitetere spamassassin? Ich habe mich für dspam entschieden, weil es anders als Spamassassin <span style="text-decoration: underline;">nicht</span> regelbasiert ist. Spamassassin legt bestimmte Regeln fest, nach denen Punkte vergeben werden und kombiniert dies mit lernenden Elementen (je nach Konfiguration). Regelbasiertes Filtern von Nachrichten hat einen Vorteil: Man hat einen sofort <span style="text-decoration: underline;">einigermaßen</span> brauchbaren Spamfiltern. Einigermaßen sage ich deswegen, weil natürlich statische Filter so allgemein sein müssen, dass sie für den eigenen spezifischen Spamschutz nicht maßgeschneidert sein können. Man wird damit, wenn man die Regeln auch noch ein bischen für sich anpasst weit kommen, allerdings sind dem Grenzen gesetzt. Mit dspam setze ich auf einen Spamfilter, der rein auf adaptives Lernen setzt und dabei <a href="http://dspam.irontec.com/faq.shtml#1.16">modernste Algorithmen</a> einsetzt. Das hat zwar den Nachteil, dass es eine Lernphase braucht und deshalb anfangs einen relativ hohen Anteil von Spam/Ham nicht richtig klassifiziert, mit der Zeit jedoch erhält man einen auf die persönlichen Bedürfnisse maßgeschneiderten Spamfilter. Diese Argumentation findet sich übrigens auch in der <a href="http://dspam.irontec.com/faq.shtml#1.7">DSPAM FAQ</a>. Ob das jetzt tatsächlich so ist, wird sich bei mir im Praxistest zeigen. Ich werde berichten..</p>
<h2>Das Spamfilter-Setup im Überblick</h2>
<p>In diesem Abschnitt möchte ich einen Überblick darüber geben, wie sich dspam in die Grundkonfiguration einfügt. Zunächst wird jede Nachricht, die exim zustellt, vor der Übergabe an den dovecot local delivery agent (LDA) von dspam analysiert und das Ergebnis im Mailheader festgehalten. Per Sieve-Filterregel kann man dann die Spammails in den Spamordner verschieben lassen. Wenn eine Mail falsch klassifiziert ist, kann man sie &#8211; falls es sich richtigerweise um Spam handelt &#8211; an spam@myserver oder andernfalls an ham@myserver schicken. Auf Dauer wäre das jedoch sehr aufwendig. Deswegen gibt es dovecot-antispam, ein Plugin für dovecot, welches beim Verschieben von Nachrichten in den Spamordner diese an spam@myserver schickt bzw. beim Verschieben von Nachrichten aus dem Spamordner in normale Ordner (nicht den Papierkorb) diese an ham@myserver schickt. DSpam kann die nutzerspezifischen Daten auf verschiedene Weisen speichern. In diesem Howto wird MySQL als Backend für dspam genutzt.</p>
<h2>Installation und Kompilieren benötigter Pakete</h2>
<p>So, beginnen wir mit einer kleinen Korrektur unserer Exim-Installation, die später bei der Prüfung von Paketabhängigkeiten wichtig wird. Wir installieren nämlich das Paket exim, welches auf eines der verschiedenen exim-Pakete verweist (wir haben <a href="http://www.effinger.org/blog/2009/03/22/dovecot-exim-openldap-und-getmail-unter-ubuntu-3-exim/">im dritten Teil des Howtos</a> den exim4-daemon-heavy installiert). Zusätzlich benötigen wir noch MySQL, das Dovecot-Antispam Plugin und dbconfig-common zur Einrichtung eines MySQL-Benutzers. Bei der Installation wird übrigens nach dem MySQL-Root-Passwort gefragt, bitte dieses unbedingt merken, denn wir benötigen es später noch.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> exim4 dovecot-antispam mysql-server dbconfig-common</pre></div></div>

<p>Im nächsten Schritt installieren wir dspam. Ich habe mich allerdings dafür entschieden, nicht die in den Repositories erhältliche Version 3.6.8 zu verwenden, sondern selbst die Pakete für die Version 3.9.0 RC2 zu erstellen. Dabei bin ich analog zu der <a href="https://juxtaposition.axley.net/2007/11/postfix-dspam-3-1.html">Beschreibung von Jason Axley</a> vorgegangen</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> build-essential
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> build-dep dspam</pre></div></div>

<p>Glücklicherweise gibt es einen aktiven Debian-Nutzer, der quasi alles (Sourcen+Patches) in einem Repository öffentlich zur Verfügung stellt unter <a href="http://packages.kirya.net/debian/pool/main/d/dspam/">http://packages.kirya.net/debian/pool/main/d/dspam/</a> (übrigens gibt es auch eine <a href="http://www.kirya.net/articles/setting-up-dspam-as-a-filter-for-postfix-on-debian-etch/">Anleitung auf kirya.net</a>). Von dort laden wir nun die Quelldateien und Patches herunter, entpacken sie und wechseln in das Unterverzeichnis dspam</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>packages.kirya.net<span style="color: #000000; font-weight: bold;">/</span>debian<span style="color: #000000; font-weight: bold;">/</span>pool<span style="color: #000000; font-weight: bold;">/</span>main<span style="color: #000000; font-weight: bold;">/</span>d<span style="color: #000000; font-weight: bold;">/</span>dspam<span style="color: #000000; font-weight: bold;">/</span>dspam_3.9.0~rc2+git20091231.orig.tar.gz
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>packages.kirya.net<span style="color: #000000; font-weight: bold;">/</span>debian<span style="color: #000000; font-weight: bold;">/</span>pool<span style="color: #000000; font-weight: bold;">/</span>main<span style="color: #000000; font-weight: bold;">/</span>d<span style="color: #000000; font-weight: bold;">/</span>dspam<span style="color: #000000; font-weight: bold;">/</span>dspam_3.9.0~rc2+git20091231-<span style="color: #000000;">1</span>.debian.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvzf dspam_3.9.0~rc2+git20091231.orig.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvzf dspam_3.9.0~rc2+git20091231-<span style="color: #000000;">1</span>.debian.tar.gz <span style="color: #660033;">-C</span> dspam
<span style="color: #7a0874; font-weight: bold;">cd</span> dspam</pre></div></div>

<p>Dann editieren wir die Datei debian/control, um die Paketabhängigkeiten so zu verändern, dass auch exim als Delivery Agent akzeptiert wird. Wir ergänzen deshalb in der depends-Zeile exim. Aus</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Package: dspam
Architecture: any
Depends: ${misc:Depends}, procmail | maildrop | courier-maildrop | sensible-mda, lsb-base (&gt;= 3.0-6), ${shlibs:Depends}</pre></div></div>

<p>wird dann</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Package: dspam
Architecture: any
Depends: ${misc:Depends}, exim4 | procmail | maildrop | courier-maildrop | sensible-mda, lsb-base (&gt;= 3.0-6), ${shlibs:Depends}</pre></div></div>

<p>Nun können wir die Binärpakete erstellen und installieren mit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">fakeroot debian<span style="color: #000000; font-weight: bold;">/</span>rules binary
<span style="color: #7a0874; font-weight: bold;">cd</span> ..
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">-i</span> dspam_3.9.0~rc2+git20091231-<span style="color: #000000;">1</span>_i386.deb libdspam7_3.9.0~rc2+git20091231-<span style="color: #000000;">1</span>_i386.deb libdspam7-drv-mysql_3.9.0~rc2+git20091231-<span style="color: #000000;">1</span>_i386.deb dspam-doc_3.9.0~rc2+git20091231-<span style="color: #000000;">1</span>_all.deb</pre></div></div>

<p>Dabei werden wir gefragt, ob die Datenbankkonfiguration jetzt oder manuell (später) erfolgen soll. Wir wählen die erste Option. Nun wird nach dem MySQL-Passwort von oben gefragt, das wir eingeben. Das Passwort für dspam können wir automatisch festlegen lassen.</p>
<h2>Konfigurationsdateien</h2>
<p>Ich habe mir die Mühe gemacht und die im Vergleich zur Standardkonfiguration, die in den Teilen (1) bis (4) beschrieben wurde, angepassten Dateien in einem <a href="http://www.effinger.org/blog/wp-content/uploads/2010/02/modified-configfiles-mailsystem-with-spam.tar.gz">Archiv</a> zusammenzupacken. Dieses Archiv ist damit <em>kein</em> Ersatz für das <a href="http://www.effinger.org/blog/wp-content/uploads/2009/03/configfiles-mailsystem.tgz">dort aufgeführte Paket der Konfigurationsdateien</a>, sondern vielmehr eine Ergänzung. Wichtige Anmerkung: Die Konfigurationsdateien können immer nur Ausgangspunkt für die eigene Konfiguration sein u.a. auch deshalb, weil die Berechtigungen für diese Dateien angepasst werden müssen!</p>
<h2>Konfiguration von dspam</h2>
<p>Jetzt machen wir uns ans Eingemachte, der Konfiguration von dspam, welches leider keine sehr ausführliche Dokumentation bietet. Es gibt jedoch eine <a href="http://www.mail-archive.com/dspam-user@lists.sourceforge.net/msg00840.html">kurze Quick-and-Dirty Anleitung von der dspam-user Mailingliste</a> und in der Readme unter /usr/share/doc/dspam/README.gz sind auch einige Informationen zu finden. Außerdem fand ich die Kommentare in einer <a href="http://www.scribd.com/doc/8019538/Dspam-Pop3-Proxy-Clamav">weiteren Anleitung</a> sehr hilfreich. Wir passen zunächst das MySQL-Datenbankschema an. Ich bevorzuge nämlich das geschwindigkeitsoptimierte Datenbankschema gegenüber dem speicherplatzoptimierten, welches standardmäßig installiert wird. Deshalb habe ich mit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql <span style="color: #660033;">-u</span> root <span style="color: #660033;">-p</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;drop database dspam; create database dspam; GRANT SELECT, INSERT, UPDATE, DELETE ON dspam.* to dspam@localhost identified by '<span style="color: #007800;">$(sudo cat /etc/dspam/dspam.d/mysql.conf | grep MySQLPass | cut -f3)</span>';&quot;</span></pre></div></div>

<p>erstmal das komplette dspam -Schema gelöscht und neu erzeugt. Dazu wird natürlich wieder das MySQL root Passwort von oben benötigt. Anschließend installieren wir mit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql <span style="color: #660033;">-u</span> dspam -p$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dspam<span style="color: #000000; font-weight: bold;">/</span>dspam.d<span style="color: #000000; font-weight: bold;">/</span>mysql.conf <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> MySQLPass <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> -f3<span style="color: #7a0874; font-weight: bold;">&#41;</span> dspam <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>libdspam7-drv-mysql<span style="color: #000000; font-weight: bold;">/</span>sql<span style="color: #000000; font-weight: bold;">/</span>mysql_objects-speed.sql</pre></div></div>

<p>das geschwindigkeitsoptimierte Datenbankschema. Wer alternativ doch das speicherplatzoptimierte Schema verwenden will, installiert es mit einem</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql <span style="color: #660033;">-u</span> dspam -p$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dspam<span style="color: #000000; font-weight: bold;">/</span>dspam.d<span style="color: #000000; font-weight: bold;">/</span>mysql.conf <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> MySQLPass <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> -f3<span style="color: #7a0874; font-weight: bold;">&#41;</span> dspam <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>libdspam7-drv-mysql<span style="color: #000000; font-weight: bold;">/</span>sql<span style="color: #000000; font-weight: bold;">/</span>mysql_objects-space.sql</pre></div></div>

<p>Nun schaffen wir die Voraussetzungen dafür, dass virtuelle Benutzer verwendet werden können. Ich habe mich dafür entschieden, dass Datenbankschema so einzurichten, dass nicht existierende Benutzer automatisch angelegt werden.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql <span style="color: #660033;">-u</span> dspam -p$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dspam<span style="color: #000000; font-weight: bold;">/</span>dspam.d<span style="color: #000000; font-weight: bold;">/</span>mysql.conf <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> MySQLPass <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> -f3<span style="color: #7a0874; font-weight: bold;">&#41;</span> dspam <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>libdspam7-drv-mysql<span style="color: #000000; font-weight: bold;">/</span>sql<span style="color: #000000; font-weight: bold;">/</span>virtual_users.sql</pre></div></div>

<p>Wer alternativ die Benutzer manuell anlegen will, führt stattdessen</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mysql <span style="color: #660033;">-u</span> dspam -p$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dspam<span style="color: #000000; font-weight: bold;">/</span>dspam.d<span style="color: #000000; font-weight: bold;">/</span>mysql.conf <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> MySQLPass <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> -f3<span style="color: #7a0874; font-weight: bold;">&#41;</span> dspam <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>doc<span style="color: #000000; font-weight: bold;">/</span>libdspam7-drv-mysql<span style="color: #000000; font-weight: bold;">/</span>sql<span style="color: #000000; font-weight: bold;">/</span>virtual_user_aliases.sql</pre></div></div>

<p>aus. Jetzt passen wir die Datei /etc/dspam/dspam.d/mysql.conf so an, dass wir virtuelle Benutzer nutzen und die Verbindung von dspam zu MySQL über einen Unix-Socket hergestellt wird (Passwort &#8211; hier donotchange &#8211; unbedingt so lassen, wie es voreingestellt ist). Mit der Option MySQLUIDInSignature legen wir fest, dass in der DSPAM-Signatur der Benutzer gespeichert wird, für den die Spam-Klassifizierung durchgeführt wurde, so dass zwei serverweite Mail-Adressen (hier ham@ und spam@) ausreichen, um die Mail umzuklassifizieren.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">MySQLServer             /var/run/mysqld/mysqld.sock
MySQLUser               dspam
MySQLPass               donotchange
MySQLDb         dspam
MySQLReconnect          true
MySQLVirtualTable               dspam_virtual_uids
MySQLVirtualUIDField            uid
MySQLVirtualUsernameField       username
MySQLUIDInSignature     on</pre></div></div>

<p>Auch die Datei /etc/dspam/dspam.conf muss angepasst werden. Wir legen secmail, der Benutzer, unter dem der Dovecot LDA Mails zustellt und mit dem später dspam von exim aufgerufen wird, als vertrauenswürdigen Benutzer fest und schließen außerdem die Konfigurationsdateien im Verzeichnis /etc/dspam/dspam.d mitein. Zudem soll die dspam-Signatur nur im Header sein, was mit der Preference  signatureLocation eingestellt wird. Die <a href="http://dspamwiki.expass.de/Preferences_Attributes">Bedeutung der einzelnen Preference-Optionen</a> wird im dspam-Wiki erklärt. Der Standardpfad für dspam.pid muss aufgrund von Berechtigungsproblemen korrigiert werden. Wir ergänzen bzw. ändern deshalb folgende Zeilen</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Trust user secmail</span>
Trust secmail
&nbsp;
<span style="color: #666666; font-style: italic;"># Changed to only have MessageIDs in the header</span>
Preference <span style="color: #ff0000;">&quot;signatureLocation=headers&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Change dspam.pid location to</span>
ServerPID               <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>dspam<span style="color: #000000; font-weight: bold;">/</span>dspam.pid
&nbsp;
<span style="color: #666666; font-style: italic;"># dspam only has to work together with the dspam client in our configuration</span>
ServerMode dspam
&nbsp;
<span style="color: #666666; font-style: italic;"># Authetication password required for dspam client</span>
<span style="color: #666666; font-style: italic;"># change secret to something else!!</span>
ServerPass.Relay1      <span style="color: #ff0000;">&quot;secret&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Use local unix socket to minimize overhead</span>
ServerDomainSocketPath <span style="color: #ff0000;">&quot;/tmp/dspam.sock&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Parameters used by dspam client to connect  to the server</span>
<span style="color: #666666; font-style: italic;"># change secret to the password you have chosen above..</span>
ClientHost     <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>dspam.sock
ClientIdent    <span style="color: #ff0000;">&quot;secret@Relay1&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Include config files from /etc/dspam/dspam.d</span>
Include <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>dspam<span style="color: #000000; font-weight: bold;">/</span>dspam.d<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Als nächstes editieren wir /etc/default/dspam und setzen die Variable START auf YES, damit dspam im Daemon-Mode beim Hochfahren des Systems gestartet wird.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Variables for dspam.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Do start dspam.</span>
<span style="color: #007800;">START</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p>Das Startskript für dspam wird angepasst, da dspam nicht automatisch in den Hintergrund geht. Deshalb editieren wir /etc/init.d/dspam und ergänzen die Option &#8211;background. Aus</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">        start-stop-daemon <span style="color: #660033;">--start</span> <span style="color: #660033;">--quiet</span> <span style="color: #660033;">--pidfile</span> <span style="color: #007800;">$PIDFILE</span> <span style="color: #660033;">--chuid</span> <span style="color: #007800;">$USER</span> <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #660033;">--</span> <span style="color: #007800;">$DAEMON_ARGS</span> \
        <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">2</span></pre></div></div>

<p>wird somit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">        start-stop-daemon <span style="color: #660033;">--start</span> <span style="color: #660033;">--quiet</span> <span style="color: #660033;">--pidfile</span> <span style="color: #007800;">$PIDFILE</span> <span style="color: #660033;">--chuid</span> <span style="color: #007800;">$USER</span> <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #660033;">--background</span> <span style="color: #660033;">--</span> <span style="color: #007800;">$DAEMON_ARGS</span> \
        <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">2</span></pre></div></div>

<p>Jetzt fügen wir noch den Benutzer secmail zur Gruppe dspam hinzu, damit es beim Aufruf von exim, der unter dem Nutzer secmail erfolgt, keine Berechtigungsprobleme gibt.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> adduser secmail dspam</pre></div></div>

<p>Nun können wir dspam im Daemon-Modus testen, indem wir es via</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> dspam <span style="color: #660033;">--debug</span> <span style="color: #660033;">--daemon</span></pre></div></div>

<p>aufrufen, um es via Strg-C nach einer Minute beenden. Ob es Probleme gibt, sollte man anhand der Logdateien im Verzeichnis /var/log/dspam und der Syslog verfolgen. Wenn das soweit geklappt hat, starten wir dspam dauerhaft mit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> service dspam start</pre></div></div>

<p>Nun prüfen wir das Zusammenspiel von Client und Server und legen gleichzeitig einen Benutzer namens globaluser an. Diesen Benutzer benötigen wir, da dspam beim Reklassifizieren einer Mail die Angabe eines Parameters &#8211;user mit gültigem User verlangt, selbst wenn es eigentlich anhand der dspam-Signatur auf den Benutzer schließen könnte, für den die Mail klassifiziert wurde. <a href="http://www.dovecot.org/list/dovecot/2006-April/012626.html">Ryan Kolak beschreibt dieses Problem ausführlicher</a>, das schon <a href="http://old.nabble.com/antispam---Unable-to-determine-the-destination-user-td20211120.html">häufiger diskutiert</a> wurde und bei dem es sich meiner Meinung nach um einen Bug handelt (Fehlermeldung:  Unable to determine the destination user). Wenn wir den Befehl</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> Subject:<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #660033;">-u</span> secmail dspam <span style="color: #660033;">--client</span> <span style="color: #660033;">--debug</span> <span style="color: #660033;">--mode</span>=notrain <span style="color: #660033;">--user</span> globaluser <span style="color: #660033;">--deliver</span>=spam,innocent <span style="color: #660033;">--stdout</span></pre></div></div>

<p>ausführen und anschließend die dspam-Statistik mit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> dspam_stats</pre></div></div>

<p>abrufen, sollten wir folgendes Ergebnis erhalten</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">globaluser        TP:     <span style="color: #000000;">0</span> TN:     <span style="color: #000000;">1</span> FP:     <span style="color: #000000;">0</span> FN:     <span style="color: #000000;">0</span> SC:     <span style="color: #000000;">0</span> NC:     <span style="color: #000000;">0</span></pre></div></div>

<p>Falls Fehler aufgetreten sind, werden diese in den obigen Logdateien bzw.der Syslog festgehalten. Die Konfiguration von dspam ist nun abgeschlossen. Einen kleinen <a href="http://www.mail-archive.com/dspam-users@lists.nuclearelephant.com/msg00156.html">Tip zu dspam von der dspam-user Mailingliste</a>, möchte ich aber noch loswerden. Mit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">strings</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">which</span> dspam<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> build</pre></div></div>

<p>lässt sich feststellen, welche Parameter beim Kompilieren von dspam verwendet wurden. Das kann hilfreich sein, denn bei dspam werden viele Optionen schon beim Kompilieren festgelegt.</p>
<h2>Anpassung der exim-Konfiguration</h2>
<p>Jetzt machen wir uns daran, Exim zu konfigurieren. Hier habe ich mich an der <a href="http://www.rm-f.de/cms/?q=node/80">Anleitung von Robert Fendt</a> und einer <a href="http://www.directadmin.com/forum/showpost.php?p=22430&amp;postcount=2">Dokumentation in einem Forum</a> orientiert. Zunächst fügen wir zu den bestehen Transporten an die lokalen Mailboxen zwei Zeilen hinzu. Der transport_filter leitet die Nachrichten durch den Spamfilter während die headers_remove Zeile dazu führt, dass in der Nachricht vorhandene DSpam-Header entfernt werden, so dass diese Header tatsächlich nur von dspam stammen können. Wir editieren also die beiden Dateien /etc/exim4/conf.d/transport/30_exim4-config_dovecot_delivery_pipe und /etc/exim4/conf.d/transport/30_exim4-config_dovecot_delivery_pipe_secmail und ergänzen die beiden erwähnten Zeilen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">  driver = pipe
  transport_filter = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>dspam <span style="color: #660033;">--deliver</span>=innocent,spam <span style="color: #660033;">--user</span> <span style="color: #ff0000;">&quot;GET_LOCAL_MAIL&quot;</span> <span style="color: #660033;">--stdout</span>
  headers_remove = X-DSPAM-Result:X-DSPAM-Processed:X-DSPAM-Confidence:X-DSPAM-Probability:X-DSPAM-Signature
  <span style="color: #7a0874; font-weight: bold;">command</span> = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>dovecot<span style="color: #000000; font-weight: bold;">/</span>deliver <span style="color: #660033;">-d</span> <span style="color: #ff0000;">&quot;GET_LOCAL_MAIL&quot;</span></pre></div></div>

<p>Jetzt müssen wir noch die beiden Mail-Adressen spam@myserver und ham@myserver einrichten. Natürlich sollen nur vom Server selbst oder von authentifizierten Benutzern E-Mails an diese Adressen geschickt werden dürfen. In der Datei /etc/exim4/conf.d/main/00_local_macros ergänzen wir deshalb Macros für eine Hostliste und diese beiden E-Mail-Adressen</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># @[] list of all local IPs</span>
<span style="color: #666666; font-style: italic;"># If exim is used localy in batch mode (exim4 -bs) then &quot;$host&quot; is empty, the &quot;: :&quot; adds the empty string.</span>
hostlist own_hosts = <span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> : :
&nbsp;
<span style="color: #666666; font-style: italic;"># address for reclassifying/learning false positive spam mails</span>
MAIL_ADDRESS_HAM = ham
&nbsp;
<span style="color: #666666; font-style: italic;"># address for reclassifying/learning undetected spam</span>
MAIL_ADDRESS_SPAM = spam</pre></div></div>

<p>Nun verweigern wir allen nicht authentifizierten Usern von entfernten Hosts das Senden von Mails durch Ergänzung der folgenden Zeilen in der Datei /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt (bitte unbedingt nach der Stelle mit accept authenticated=*)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Accept if the message arrived over an authenticated connection, from</span>
<span style="color: #666666; font-style: italic;"># any host. Again, these messages are usually from MUAs, so recipient</span>
<span style="color: #666666; font-style: italic;"># verification is omitted, and submission mode is set. And again, we do this</span>
<span style="color: #666666; font-style: italic;"># check before any black list tests.</span>
accept
  authenticated = <span style="color: #000000; font-weight: bold;">*</span>
  <span style="color: #666666; font-style: italic;"># Nur unter der Bedingung, dass der Absender ein valider, entfernter User in LDAP</span>
  <span style="color: #666666; font-style: italic;"># ist Empfänger bedingungslos akzeptieren</span>
  condition = IS_SENDER_REMOTE
  <span style="color: #666666; font-style: italic;">#control = submission/sender_retain</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Deny all unauthenticated remote hosts to send mail to</span>
<span style="color: #666666; font-style: italic;"># spam or ham email addresses</span>
deny
  hosts = <span style="color: #000000; font-weight: bold;">!</span>+own_hosts
  local_parts = MAIL_ADDRESS_HAM : MAIL_ADDRESS_SPAM</pre></div></div>

<p>Jetzt brauchen wir nur noch einen Router und einen Transporter für das Lernen von Spam bzw. Ham. Den Router erzeugen wir durch die Datei /etc/exim4/conf.d/router/410_exim4-config_spam_classification mit folgendem Inhalt</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">################################################</span>
<span style="color: #666666; font-style: italic;">### router/410_exim4-config_spam_classification</span>
<span style="color: #666666; font-style: italic;">################################################</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This router matches the local spam and ham mailboxes</span>
<span style="color: #666666; font-style: italic;"># which are used to train the spam filter with false</span>
<span style="color: #666666; font-style: italic;"># spam positives or unrecognized spam.</span>
&nbsp;
router_spam_training:
  debug_print = <span style="color: #ff0000;">&quot;R: spam training issued by mail from <span style="color: #007800;">$sender_address</span>@<span style="color: #007800;">$sender_address_domain</span> to <span style="color: #007800;">$local_part</span>@<span style="color: #007800;">$domain</span>&quot;</span>
  driver = accept
  domains = +local_domains
  local_parts = MAIL_ADDRESS_HAM : MAIL_ADDRESS_SPAM
  transport = transport_spam_training
&nbsp;
<span style="color: #666666; font-style: italic;">################################################</span>
<span style="color: #666666; font-style: italic;">### router/410_exim4-config_spam_classification</span>
<span style="color: #666666; font-style: italic;">################################################</span></pre></div></div>

<p>Den Transporter erstellen wir analog durch die Datei /etc/exim4/conf.d/transport/30_exim4-config_transport_spam_training mit dem Inhalt</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#####################################################</span>
<span style="color: #666666; font-style: italic;">### transport/30_exim4-config_transport_spam_training</span>
<span style="color: #666666; font-style: italic;">#####################################################</span>
&nbsp;
transport_spam_training:
  debug_print = <span style="color: #ff0000;">&quot;T: spam training issued by mail from <span style="color: #007800;">$sender_address</span>@<span style="color: #007800;">$sender_address_domain</span> to <span style="color: #007800;">$local_part</span>@<span style="color: #007800;">$domain</span>&quot;</span>
  driver = pipe
  <span style="color: #7a0874; font-weight: bold;">command</span> = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>dspam <span style="color: #ff0000;">&quot;<span style="color: #007800;">${if eq{$local_part}</span>{MAIL_ADDRESS_HAM} {--class=innocent}{--class=spam}}&quot;</span> <span style="color: #660033;">--source</span>=error <span style="color: #660033;">--delivery</span>=stdout <span style="color: #660033;">--user</span> globaluser
  message_prefix =
  message_suffix =
  <span style="color: #666666; font-style: italic;"># Do not add additional Headers</span>
  delivery_date_add = <span style="color: #c20cb9; font-weight: bold;">false</span>
  envelope_to_add = <span style="color: #c20cb9; font-weight: bold;">false</span>
  return_path_add = <span style="color: #c20cb9; font-weight: bold;">false</span>
  log_output
  user = secmail
  group = secmail
&nbsp;
<span style="color: #666666; font-style: italic;">#####################################################</span>
<span style="color: #666666; font-style: italic;">### transport/30_exim4-config_transport_spam_training</span>
<span style="color: #666666; font-style: italic;">#####################################################</span></pre></div></div>

<p>Was mich lange aufgehalten hat, waren die String-Expansions in der command Angabe. Hier kommt es darauf an, die Anführungszeichen zu setzen, wie es sowohl in der <a href="http://wiki.exim.org/FAQ/General_Debugging/Q0025">FAQ</a> als auch in der <a href="http://exim.org/exim-html-4.71/doc/html/spec_html/ch29.html#SECThowcommandrun">Dokumentation von command</a> und unter anderem auch bei der von <a href="http://www.exim.org/exim-html-4.71/doc/html/spec_html/ch24.html#id603010">transport_filter</a> erwähnt wird. Der Grund, warum hier für dspam nicht der Parameter &#8211;stdout, sondern &#8211;delivery=stdout gewählt wurde, liegt darin, dass ansonsten teilweise die Fehlermeldung &#8220;Client exited with error -5&#8243; auftaucht. <a href="http://marc.info/?l=dspam-users&amp;m=120836028609994&amp;w=2">Dieser Hinweis zur Fehlerbehebung stammt übrigens von der dspam-users Mailinglist</a>. Abschließend wird die Konfigurationsdatei erzeugt und Exim neu gestartet durch ein</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> update-exim4.conf <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>exim4 restart</pre></div></div>

<p>Nun kann man mit dem Befehl</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> Subject:<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #660033;">-u</span> secmail dspam <span style="color: #660033;">--client</span> <span style="color: #660033;">--debug</span> <span style="color: #660033;">--mode</span>=notrain <span style="color: #660033;">--user</span> globaluser <span style="color: #660033;">--deliver</span>=spam,innocent <span style="color: #660033;">--stdout</span> <span style="color: #000000; font-weight: bold;">|</span> mail <span style="color: #660033;">-s</span> <span style="color: #ff0000;">&quot;Reclassify&quot;</span> spam</pre></div></div>

<p>testen, ob die Konfiguration funktioniert. Ein erneutes</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> dspam_stats</pre></div></div>

<p>sollte dann dieses Ergebnis</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">globaluser        TP:     <span style="color: #000000;">0</span> TN:     <span style="color: #000000;">1</span> FP:     <span style="color: #000000;">0</span> FN:     <span style="color: #000000;">1</span> SC:     <span style="color: #000000;">0</span> NC:     <span style="color: #000000;">0</span></pre></div></div>

<p>ausgeben.</p>
<h2>Einrichtung des dovecot-antispam Plugins</h2>
<p>Im nächsten Schritt konfigurieren wir das dovecot-antispam plugin. Bei diesem Plugin wird <span style="text-decoration: underline;">beim Kompilieren</span> festgelegt, welches Backend (dspam-exec, mailtrain oder crm114-exec) verwendet werden soll. Wenn man die Paket-Version von Debian/Ubuntu verwendet, ist man deshalb automatisch auf das mailtrain-Backend festgelegt. Dies kann man zwar erst der <a href="http://packages.ubuntu.com/lucid/utils/dovecot-antispam">Beschreibung des Pakets in Lucid Lynx</a> lesen, trifft aber auch auf vorherige Versionen zu. Passen wir also jetzt die Konfigurationsdatei unter /etc/dovecot/dovecot.conf an. Wir aktivieren das antispam-Plugin im Imap-Abschnitt folgendermaßen</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">protocol imap <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  mail_plugins = antispam
  <span style="color: #666666; font-style: italic;"># mail_plugin_dir = /usr/lib/dovecot/modules/imap</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>anschließend ergänzen wir den plugin-Abschnitt um die Konfigurationsparameter für dovecot-antispam. Dabei sind unter Umständen die Ordnerbezeichnungen für den Papierkorb und Spam anzupassen.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">plugin <span style="color: #7a0874; font-weight: bold;">&#123;</span>
 <span style="color: #666666; font-style: italic;">##################</span>
 <span style="color: #666666; font-style: italic;"># DSPAM</span>
 <span style="color: #666666; font-style: italic;"># GENERIC OPTIONS</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># mail signature (used with any backend requiring a signature)</span>
 antispam_signature = X-DSPAM-Signature
&nbsp;
 <span style="color: #666666; font-style: italic;"># action to take on mails without signature</span>
 <span style="color: #666666; font-style: italic;"># (used with any backend requiring a signature)</span>
 <span style="color: #666666; font-style: italic;"># (we recommend only setting this to 'move' after verifying that the</span>
 <span style="color: #666666; font-style: italic;"># whole setup is working)</span>
 <span style="color: #666666; font-style: italic;"># antispam_signature_missing = move # move silently without training</span>
 antispam_signature_missing = move
&nbsp;
 <span style="color: #666666; font-style: italic;"># semicolon-separated list of Trash folders (default unset i.e. none)</span>
 <span style="color: #666666; font-style: italic;"># antispam_trash =</span>
 antispam_trash = trash;Trash;Deleted Items
&nbsp;
 <span style="color: #666666; font-style: italic;"># semicolon-separated list of spam folders</span>
 antispam_spam = SPAM;Spam;spam
&nbsp;
 <span style="color: #666666; font-style: italic;"># semicolon-separated list of unsure folders (default unset i.e. none)</span>
 <span style="color: #666666; font-style: italic;"># antispam_unsure =</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># Whether to allow APPENDing to SPAM folders or not. Must be set to</span>
 <span style="color: #666666; font-style: italic;"># &quot;yes&quot; (case insensitive) to be activated. Before activating, please</span>
 <span style="color: #666666; font-style: italic;"># read the discussion below.</span>
 <span style="color: #666666; font-style: italic;"># antispam_allow_append_to_spam = no</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">###########################</span>
 <span style="color: #666666; font-style: italic;"># BACKEND SPECIFIC OPTIONS</span>
 <span style="color: #666666; font-style: italic;"># please note: the backend has to be specified at compile time</span>
 <span style="color: #666666; font-style: italic;"># the backend used in the Debian/Ubuntu standard package is mailtrain</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">#===================</span>
 <span style="color: #666666; font-style: italic;"># dspam-exec plugin</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># dspam binary</span>
 antispam_dspam_binary = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>dspam
&nbsp;
 <span style="color: #666666; font-style: italic;"># semicolon-separated list of extra arguments to dspam</span>
 <span style="color: #666666; font-style: italic;"># (default unset i.e. none)</span>
 <span style="color: #666666; font-style: italic;"># antispam_dspam_args =</span>
 <span style="color: #666666; font-style: italic;"># antispam_dspam_args = --deliver=;--user;%u  # % expansion done by dovecot</span>
 <span style="color: #666666; font-style: italic;"># antispam_dspam_args = --mode=teft</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># Ignore mails where the DSPAM result header contains any of the</span>
 <span style="color: #666666; font-style: italic;"># strings listed in the blacklist</span>
 <span style="color: #666666; font-style: italic;"># (default unset i.e. none)</span>
 <span style="color: #666666; font-style: italic;"># antispam_dspam_result_header = X-DSPAM-Result</span>
 <span style="color: #666666; font-style: italic;"># semicolon-separated list of blacklisted results, case insensitive</span>
 <span style="color: #666666; font-style: italic;"># antispam_dspam_result_blacklist = Virus</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">#=====================</span>
 <span style="color: #666666; font-style: italic;"># mail sending plugin</span>
 <span style="color: #666666; font-style: italic;">#</span>
 <span style="color: #666666; font-style: italic;"># Because of the way this plugin works, you can also use it</span>
 <span style="color: #666666; font-style: italic;"># to train via an arbitrary program that receives the message</span>
 <span style="color: #666666; font-style: italic;"># on standard input, in that case you can use the config</span>
 <span style="color: #666666; font-style: italic;"># options antispam_mail_spam and antispam_mail_notspam for</span>
 <span style="color: #666666; font-style: italic;"># the argument that distinguishes between ham and spam.</span>
 <span style="color: #666666; font-style: italic;"># For example:</span>
 <span style="color: #666666; font-style: italic;">#   antispam_mail_sendmail = /path/to/mailtrain</span>
 <span style="color: #666666; font-style: italic;">#   antispam_mail_sendmail_args = --for;%u</span>
 <span style="color: #666666; font-style: italic;">#   antispam_mail_spam = --spam</span>
 <span style="color: #666666; font-style: italic;">#   antispam_mail_notspam = --ham</span>
 <span style="color: #666666; font-style: italic;"># will call it, for example, like this:</span>
 <span style="color: #666666; font-style: italic;">#   /path/to/mailtrain --for jberg --spam</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># temporary directory</span>
 antispam_mail_tmpdir = <span style="color: #000000; font-weight: bold;">/</span>tmp
&nbsp;
 <span style="color: #666666; font-style: italic;"># spam/not-spam addresses (default unset which will give errors)</span>
 antispam_mail_spam = spam
 antispam_mail_notspam = ham
&nbsp;
 <span style="color: #666666; font-style: italic;"># sendmail binary</span>
 antispam_mail_sendmail = <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sendmail</span>
 <span style="color: #666666; font-style: italic;">#antispam_mail_sendmail_args = -f;%u@example.com # % expansion done by dovecot</span>
&nbsp;
 <span style="color: #666666; font-style: italic;">#===================</span>
 <span style="color: #666666; font-style: italic;"># crm114-exec plugin</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># mailreaver binary</span>
 antispam_crm_binary = <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">false</span>
 <span style="color: #666666; font-style: italic;"># antispam_crm_binary = /usr/share/crm114/mailreaver.crm</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># semicolon-separated list of extra arguments to dspam</span>
 <span style="color: #666666; font-style: italic;"># (default unset i.e. none)</span>
 <span style="color: #666666; font-style: italic;"># antispam_crm_args =</span>
 <span style="color: #666666; font-style: italic;"># antispam_crm_args = --config=/path/to/config</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># NOTE: you need to set the signature for this backend</span>
 antispam_signature = X-CRM114-CacheID
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<h2>Sieve zum automatischen Verschieben der Spamnachrichten</h2>
<p>Das Einzige, was jetzt noch fehlt, ist die Einrichtung des Sieve-Filters durch den die Spam-Nachrichten direkt in den Spam-Ordner verschoben und als gelesen markiert werden. Auch hier bitte ggfs. den Namen des Spamordners anpassen.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">require <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">&quot;fileinto&quot;</span>,<span style="color: #ff0000;">&quot;imapflags&quot;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;"># Spam</span>
<span style="color: #666666; font-style: italic;"># Catch mail tagged as spam, except spam retrained and delivered to the mailbox</span>
<span style="color: #000000; font-weight: bold;">if</span> allof<span style="color: #7a0874; font-weight: bold;">&#40;</span>header :contains <span style="color: #ff0000;">&quot;X-DSPAM-Result&quot;</span> <span style="color: #ff0000;">&quot;Spam&quot;</span>,
 not header :contains <span style="color: #ff0000;">&quot;X-DSPAM-Reclassified&quot;</span> <span style="color: #ff0000;">&quot;Innocent&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
&nbsp;
 <span style="color: #666666; font-style: italic;"># Mark as read</span>
 setflag <span style="color: #ff0000;">&quot;\\Seen&quot;</span>;
&nbsp;
 <span style="color: #666666; font-style: italic;"># Move into the Junk folder</span>
 fileinto <span style="color: #ff0000;">&quot;Spam&quot;</span>;
&nbsp;
 <span style="color: #666666; font-style: italic;"># Stop processing here</span>
 stop;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># The rest goes into INBOX</span>
<span style="color: #666666; font-style: italic;"># default is &quot;implicit keep&quot;, we do it explicitly here</span>
keep;</pre></div></div>

<p>So, damit ist der Spamfilter fertig eingerichtet. Was jetzt noch fehlt, ist das Webinterface für dspam (das Binär-Paket dafür haben wir aber schon erzeugt) und der Webmail-Zugriff mit Roundcube. Fortsetzung folgt..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.effinger.org/blog/2010/02/20/dovecot-exim-openldap-und-getmail-unter-ubuntu-%e2%80%93-5-dspam/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

