<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.muonpi.org/index.php?action=history&amp;feed=atom&amp;title=Spam_filtering</id>
	<title>Spam filtering - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.muonpi.org/index.php?action=history&amp;feed=atom&amp;title=Spam_filtering"/>
	<link rel="alternate" type="text/html" href="https://wiki.muonpi.org/index.php?title=Spam_filtering&amp;action=history"/>
	<updated>2026-04-21T04:03:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.muonpi.org/index.php?title=Spam_filtering&amp;diff=809&amp;oldid=prev</id>
		<title>Simonglm: Created page with &quot;Our website uses '''postfix''' as it's MTA (mail transport agent), which also has the ability to forward incoming mails to so called ''MILTERS'' (&quot;mail filters&quot;). One of those...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.muonpi.org/index.php?title=Spam_filtering&amp;diff=809&amp;oldid=prev"/>
		<updated>2023-02-12T18:49:59Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Our website uses &amp;#039;&amp;#039;&amp;#039;postfix&amp;#039;&amp;#039;&amp;#039; as it&amp;#039;s MTA (mail transport agent), which also has the ability to forward incoming mails to so called &amp;#039;&amp;#039;MILTERS&amp;#039;&amp;#039; (&amp;quot;mail filters&amp;quot;). One of those...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Our website uses '''postfix''' as it's MTA (mail transport agent), which also has the ability to forward incoming mails to so called ''MILTERS'' (&amp;quot;mail filters&amp;quot;).&lt;br /&gt;
One of those milters configured on our server is the spam filter '''Rspamd'''.&lt;br /&gt;
&lt;br /&gt;
The WebUI of the service is located at [http://rspamd.muonpi.org rspamd.muonpi.org].&lt;br /&gt;
The rspamd service itself is running on &amp;lt;code&amp;gt;localhost:11332&amp;lt;/code&amp;gt; with the UI running on &amp;lt;code&amp;gt;localhost:11334&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Terminology===&lt;br /&gt;
''Spam'' is unwanted mail, while ''Ham'' is referring to false positives.&lt;br /&gt;
&lt;br /&gt;
From Wikipedia on [https://en.wikipedia.org/wiki/Spam_(food) Spam (food)]:&lt;br /&gt;
&amp;lt;blockquote&amp;gt;Spam has affected popular culture, including a Monty Python skit, which repeated the name many times, leading to its name being borrowed to describe unsolicited electronic messages, especially email.&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
Setup and configuration was done according to [https://rspamd.com/doc/integration.html this guide].&lt;br /&gt;
Configuration for postfix is rather simple, just add &amp;lt;code&amp;gt;inet:localhost:11332&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;smtpd_milters&amp;lt;/code&amp;gt; field:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;smtpd_milters = unix:/opendkim/opendkim.sock,inet:localhost:11332&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Training the filter==&lt;br /&gt;
Rspamd has the ability to learn to better filter spam. The training data is stored using a '''redis''' database.&lt;br /&gt;
&lt;br /&gt;
Training can be done by two different methods: Via the WebUIs ''Scan/Learn'' Section of via the command line interface &amp;lt;code&amp;gt;rspamc&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== The WebUI===&lt;br /&gt;
After logging into the WebUI you can see the status of the filter. On the right hand side, a pie chart shows how many mails have been processed and the portions of rejected or annotated mails. &lt;br /&gt;
The Table  named ''Bayesian statistics'' shows how many mails have been declared as 'Spam' or as 'Ham'.&lt;br /&gt;
&lt;br /&gt;
Training is done in the '''Scan/Learn''' tab of the WebUI. Paste the raw message source into the text field and click '''Scan message'''.&lt;br /&gt;
Below you will see the result of the scan. The 'action' indicates what Rspamd would do if it where to receive that mail.&lt;br /&gt;
The symbols listed give the merits on which a message was evaluated.&lt;br /&gt;
They can either have a positive or negative value, indicating if their presence indicates if the given message is ''spam'' or ''ham''.&lt;br /&gt;
&lt;br /&gt;
You can tell rspamd to learn from this message by choosing '''Upload Ham''' or '''Upload Spam'''.&lt;br /&gt;
&lt;br /&gt;
=== The CLI ===&lt;br /&gt;
Similar to the WebUI, you can check if a given mail is spam or not by calling &amp;lt;code&amp;gt;rspamc suspicious.eml&amp;lt;/code&amp;gt;.&lt;br /&gt;
After analysis, the found symbols and the collective score is shown.&lt;br /&gt;
To train the filter on this suspicious mail call &amp;lt;code&amp;gt;rspamc learn_spam suspicious.eml&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;rspamc learn_ham suspicious.eml&amp;lt;/code&amp;gt; respectively.&lt;br /&gt;
&lt;br /&gt;
== Dovecot CLI: 'doveadm' ==&lt;br /&gt;
Since most of the incomming mail is recieved by OSTicket via ''support@muonpi.org'' which does not provide the raw message source in the tickets, &amp;lt;code&amp;gt;doveadm&amp;lt;/code&amp;gt; is used to get the message source.&lt;br /&gt;
&lt;br /&gt;
'''NOTE''': This can only be done with superuser permissions and gives full read/write access to '''all''' users mails. So be careful!&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;doveadm search [-u &amp;lt;user&amp;gt;|-A] [-S &amp;lt;socket_path&amp;gt;] &amp;lt;search query&amp;gt;&amp;lt;/code&amp;gt; to search for mails. See [https://wiki.dovecot.org/Tools/Doveadm/Search wiki.dovecot.org] for command reference and [https://wiki2.dovecot.org/Tools/Doveadm/SearchQuery this page] for ''search_query'' reference.&lt;br /&gt;
&lt;br /&gt;
This one-liner will search and save mails from user &amp;lt;user&amp;gt; which were sent/recieved on the date &amp;lt;YYYY-MM-DD&amp;gt;:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;doveadm search -u &amp;lt;user&amp;gt; ON &amp;lt;YYYY-MM-DD&amp;gt; | while read guid uid; do doveadm fetch -u &amp;lt;user&amp;gt; text mailbox-guid $guid uid $uid &amp;gt; $uid.eml; done&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Simonglm</name></author>
		
	</entry>
</feed>