<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.kinguardproject.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=G%C3%B6ran</id>
	<title>The Kinguard Project Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.kinguardproject.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=G%C3%B6ran"/>
	<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=Special:Contributions/G%C3%B6ran"/>
	<updated>2026-04-16T12:05:03Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=125</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=125"/>
		<updated>2020-03-05T09:23:03Z</updated>

		<summary type="html">&lt;p&gt;Göran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved dovecot-lmtpd&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf (uncomment/edit as below)&lt;br /&gt;
 service lmtp {&lt;br /&gt;
  unix_listener /var/spool/postfix/private/dovecot-lmtp {&lt;br /&gt;
   group = postfix&lt;br /&gt;
   mode = 0600&lt;br /&gt;
   user = postfix&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf and change the &amp;quot;mail_location&amp;quot; parameter&lt;br /&gt;
 mail_location = maildir:/var/opi/mail/data/&#039;&#039;&#039;%n&#039;&#039;&#039;/mail &lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%n/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%n/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix/main.cf and at the end add the line&lt;br /&gt;
 virtual_transport = lmtp:unix:private/dovecot-lmtp&lt;br /&gt;
&lt;br /&gt;
Restart services&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
=== Global filtering ===&lt;br /&gt;
If you want to have filters that are executed for all users try the following&lt;br /&gt;
&lt;br /&gt;
Create a location for global scripts&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d&lt;br /&gt;
To be able to run then before and/or after user&#039;s personal filters create additional folders&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/before&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Create scritps in the appropriate sub folder, this is a filter for mail marked as spam by spamassasin&lt;br /&gt;
Create /etc/kinguard/sieve.d/before/10-junk.sieve&lt;br /&gt;
 require [&amp;quot;fileinto&amp;quot;, &amp;quot;mailbox&amp;quot;];&lt;br /&gt;
 if header :contains &amp;quot;X-Spam-Flag&amp;quot; &amp;quot;YES&amp;quot; {&lt;br /&gt;
    fileinto :create &amp;quot;Junk&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
The script needs to be compiled since this can not be done run-time by dovecot as it does not have permissions here&lt;br /&gt;
 cd /etc/kinguard/sieve.d/before&lt;br /&gt;
 sievec 10-junk.sieve&lt;br /&gt;
&lt;br /&gt;
Add the locations to /etc/dovecot/conf.d/90-sieve.conf&lt;br /&gt;
  sieve_before = /etc/kinguard/sieve.d/before&lt;br /&gt;
  sieve_after = /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Restart dovecot&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
To get some additional information on what is going on, enable mail_debug in /etc/dovecot/conf.d/10-logging.conf&lt;br /&gt;
 mail_debug = yes&lt;br /&gt;
&amp;quot;tail -f /var/log/mail.log&amp;quot; is your friend here.&lt;br /&gt;
=== Exemple Filters ===&lt;br /&gt;
[https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples Examples]&lt;br /&gt;
&lt;br /&gt;
=== Useful links ===&lt;br /&gt;
[https://www.fastmail.com/cgi-bin/sievetest.pl Filter tester]&lt;br /&gt;
[https://www.fastmail.com/help/technical/sieve-faq.html Small FAQ]&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=124</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=124"/>
		<updated>2020-03-05T08:08:51Z</updated>

		<summary type="html">&lt;p&gt;Göran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Work in progress.....&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved dovecot-lmtpd&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf (uncomment/edit as below)&lt;br /&gt;
 service lmtp {&lt;br /&gt;
  unix_listener /var/spool/postfix/private/dovecot-lmtp {&lt;br /&gt;
   group = postfix&lt;br /&gt;
   mode = 0600&lt;br /&gt;
   user = postfix&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf and change the &amp;quot;mail_location&amp;quot; parameter&lt;br /&gt;
 mail_location = maildir:/var/opi/mail/data/&#039;&#039;&#039;%n&#039;&#039;&#039;/mail &lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%n/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%n/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix/main.cf and at the end add the line&lt;br /&gt;
 virtual_transport = lmtp:unix:private/dovecot-lmtp&lt;br /&gt;
&lt;br /&gt;
Restart services&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
=== Global filtering ===&lt;br /&gt;
If you want to have filters that are executed for all users try the following&lt;br /&gt;
&lt;br /&gt;
Create a location for global scripts&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d&lt;br /&gt;
To be able to run then before and/or after user&#039;s personal filters create additional folders&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/before&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Create scritps in the appropriate sub folder, this is a filter for mail marked as spam by spamassasin&lt;br /&gt;
Create /etc/kinguard/sieve.d/before/10-junk.sieve&lt;br /&gt;
 require [&amp;quot;fileinto&amp;quot;, &amp;quot;mailbox&amp;quot;];&lt;br /&gt;
 if header :contains &amp;quot;X-Spam-Flag&amp;quot; &amp;quot;YES&amp;quot; {&lt;br /&gt;
    fileinto :create &amp;quot;Junk&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
The script needs to be compiled since this can not be done run-time by dovecot as it does not have permissions here&lt;br /&gt;
 cd /etc/kinguard/sieve.d/before&lt;br /&gt;
 sievec 10-junk.sieve&lt;br /&gt;
&lt;br /&gt;
Add the locations to /etc/dovecot/conf.d/90-sieve.conf&lt;br /&gt;
  sieve_before = /etc/kinguard/sieve.d/before&lt;br /&gt;
  sieve_after = /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Restart dovecot&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
To get some additional information on what is going on, enable mail_debug in /etc/dovecot/conf.d/10-logging.conf&lt;br /&gt;
 mail_debug = yes&lt;br /&gt;
&amp;quot;tail -f /var/log/mail.log&amp;quot; is your friend here.&lt;br /&gt;
=== Exemple Filters ===&lt;br /&gt;
[https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples Examples]&lt;br /&gt;
&lt;br /&gt;
=== Useful links ===&lt;br /&gt;
[https://www.fastmail.com/cgi-bin/sievetest.pl Filter tester]&lt;br /&gt;
[https://www.fastmail.com/help/technical/sieve-faq.html Small FAQ]&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=123</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=123"/>
		<updated>2020-03-05T08:05:04Z</updated>

		<summary type="html">&lt;p&gt;Göran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Work in progress.....&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved dovecot-lmtpd&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf (uncomment/edit as below)&lt;br /&gt;
 service lmtp {&lt;br /&gt;
  unix_listener /var/spool/postfix/private/dovecot-lmtp {&lt;br /&gt;
   group = postfix&lt;br /&gt;
   mode = 0600&lt;br /&gt;
   user = postfix&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf and change the &amp;quot;mail_location&amp;quot; parameter&lt;br /&gt;
 mail_location = maildir:/var/opi/mail/data/&#039;&#039;&#039;%n&#039;&#039;&#039;/mail &lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%n/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%n/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix/main.cf and at the end add the line&lt;br /&gt;
 virtual_transport = lmtp:unix:private/dovecot-lmtp&lt;br /&gt;
&lt;br /&gt;
Restart services&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
=== Global filtering ===&lt;br /&gt;
If you want to have filters that are executed for all users try the following&lt;br /&gt;
&lt;br /&gt;
Create a location for global scripts&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d&lt;br /&gt;
To be able to run then before and/or after user&#039;s personal filters create additional folders&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/before&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Create scritps in the sieve.d folder, this is a filter for mail marked as spam by spamassasin&lt;br /&gt;
Create /etc/kinguard/sieve.d/junk.sieve&lt;br /&gt;
 require [&amp;quot;fileinto&amp;quot;, &amp;quot;mailbox&amp;quot;];&lt;br /&gt;
 if header :contains &amp;quot;X-Spam-Flag&amp;quot; &amp;quot;YES&amp;quot; {&lt;br /&gt;
    fileinto :create &amp;quot;Junk&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
The script needs to be compiled since this can not be done run-time by dovecot as it does not have permissions here&lt;br /&gt;
 cd /etc/kinguard/sieve.d&lt;br /&gt;
 sievec junk.sieve&lt;br /&gt;
&lt;br /&gt;
To run it before the users filters&lt;br /&gt;
 ln -s /etc/kinguard/sieve.d/junk.sieve /etc/kinguard/sieve.d/before/10-junk.sieve&lt;br /&gt;
 ln -s /etc/kinguard/sieve.d/junk.svbin /etc/kinguard/sieve.d/before/10-junk.svbin&lt;br /&gt;
&lt;br /&gt;
Add the locations to /etc/dovecot/conf.d/90-sieve.conf&lt;br /&gt;
  sieve_before = /etc/kinguard/sieve.d/before&lt;br /&gt;
  sieve_after = /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Restart dovecot&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
To get some additional information on what is going on, enable mail_debug in /etc/dovecot/conf.d/10-logging.conf&lt;br /&gt;
 mail_debug = yes&lt;br /&gt;
&amp;quot;tail -f /var/log/mail.log&amp;quot; is your friend here.&lt;br /&gt;
=== Exemple Filters ===&lt;br /&gt;
[https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples Examples]&lt;br /&gt;
&lt;br /&gt;
=== Useful links ===&lt;br /&gt;
[https://www.fastmail.com/cgi-bin/sievetest.pl Filter tester]&lt;br /&gt;
[https://www.fastmail.com/help/technical/sieve-faq.html Small FAQ]&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=122</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=122"/>
		<updated>2020-03-05T07:57:37Z</updated>

		<summary type="html">&lt;p&gt;Göran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Work in progress.....&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved dovecot-lmtpd&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf (uncomment/edit as below)&lt;br /&gt;
 service lmtp {&lt;br /&gt;
  unix_listener /var/spool/postfix/private/dovecot-lmtp {&lt;br /&gt;
   group = postfix&lt;br /&gt;
   mode = 0600&lt;br /&gt;
   user = postfix&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf and change the &amp;quot;mail_location&amp;quot; parameter&lt;br /&gt;
 mail_location = maildir:/var/opi/mail/data/&#039;&#039;&#039;%n&#039;&#039;&#039;/mail &lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%n/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%n/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix/main.cf and at the end add the line&lt;br /&gt;
 virtual_transport = lmtp:unix:private/dovecot-lmtp&lt;br /&gt;
&lt;br /&gt;
Restart services&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
=== Global filtering ===&lt;br /&gt;
If you want to have filters that are executed for all users try the following&lt;br /&gt;
&lt;br /&gt;
Create a location for global scripts&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d&lt;br /&gt;
To be able to run then before and/or after user&#039;s personal filters create additional folders&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/before&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Create scritps in the sieve.d folder, this is a filter for mail marked as spam by spamassasin&lt;br /&gt;
Create /etc/kinguard/sieve.d/junk.sieve&lt;br /&gt;
 require [&amp;quot;fileinto&amp;quot;, &amp;quot;mailbox&amp;quot;];&lt;br /&gt;
 if header :contains &amp;quot;X-Spam-Flag&amp;quot; &amp;quot;YES&amp;quot; {&lt;br /&gt;
    fileinto :create &amp;quot;Junk&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
The script needs to be compiled since this can not be done run-time by dovecot as it does not have permissions here&lt;br /&gt;
 cd /etc/kinguard/sieve.d&lt;br /&gt;
 sievec junk.sieve&lt;br /&gt;
&lt;br /&gt;
To run it before the users filters&lt;br /&gt;
 ln -s /etc/kinguard/sieve.d/junk.sieve /etc/kinguard/sieve.d/before/10-junk.sieve&lt;br /&gt;
&lt;br /&gt;
Add the locations to /etc/dovecot/conf.d/90-sieve.conf&lt;br /&gt;
  sieve_before = /etc/kinguard/sieve.d/before&lt;br /&gt;
  sieve_after = /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Restart dovecot&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
To get some additional information on what is going on, enable mail_debug in /etc/dovecot/conf.d/10-logging.conf&lt;br /&gt;
 mail_debug = yes&lt;br /&gt;
&amp;quot;tail -f /var/log/mail.log&amp;quot; is your friend here.&lt;br /&gt;
=== Exemple Filters ===&lt;br /&gt;
[https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples Examples]&lt;br /&gt;
&lt;br /&gt;
=== Useful links ===&lt;br /&gt;
[https://www.fastmail.com/cgi-bin/sievetest.pl Filter tester]&lt;br /&gt;
[https://www.fastmail.com/help/technical/sieve-faq.html Small FAQ]&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=121</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=121"/>
		<updated>2020-03-05T07:51:56Z</updated>

		<summary type="html">&lt;p&gt;Göran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Work in progress.....&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved dovecot-lmtpd&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf (uncomment/edit as below)&lt;br /&gt;
 service lmtp {&lt;br /&gt;
  unix_listener /var/spool/postfix/private/dovecot-lmtp {&lt;br /&gt;
   group = postfix&lt;br /&gt;
   mode = 0600&lt;br /&gt;
   user = postfix&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf and change the &amp;quot;mail_location&amp;quot; parameter&lt;br /&gt;
 mail_location = maildir:/var/opi/mail/data/&#039;&#039;&#039;%n&#039;&#039;&#039;/mail &lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%n/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%n/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix/main.cf and at the end add the line&lt;br /&gt;
 virtual_transport = lmtp:unix:private/dovecot-lmtp&lt;br /&gt;
&lt;br /&gt;
Restart services&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
=== Global filtering ===&lt;br /&gt;
If you want to have filters that are executed for all users try the following&lt;br /&gt;
&lt;br /&gt;
Create a location for global scripts&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d&lt;br /&gt;
To be able to run then before and/or after user&#039;s personal filters create additional folders&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/before&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Create scritps in the sieve.d folder, this is a filter for mail marked as spam by spamassasin&lt;br /&gt;
Create /etc/kinguard/sieve.d/junk.sieve&lt;br /&gt;
 require [&amp;quot;fileinto&amp;quot;, &amp;quot;mailbox&amp;quot;];&lt;br /&gt;
 if header :contains &amp;quot;X-Spam-Flag&amp;quot; &amp;quot;YES&amp;quot; {&lt;br /&gt;
    fileinto :create &amp;quot;Junk&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
To run it before the users filters&lt;br /&gt;
 ln -s /etc/kinguard/sieve.d/junk.sieve /etc/kinguard/sieve.d/before/10-junk.sieve&lt;br /&gt;
&lt;br /&gt;
Add the locations to /etc/dovecot/conf.d/90-sieve.conf&lt;br /&gt;
  sieve_before = /etc/kinguard/sieve.d/before&lt;br /&gt;
  sieve_after = /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Restart dovecot&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
To get some additional information on what is going on, enable mail_debug in /etc/dovecot/conf.d/10-logging.conf&lt;br /&gt;
 mail_debug = yes&lt;br /&gt;
&amp;quot;tail -f /var/log/mail.log&amp;quot; is your friend here.&lt;br /&gt;
=== Exemple Filters ===&lt;br /&gt;
[https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples Examples]&lt;br /&gt;
&lt;br /&gt;
=== Useful links ===&lt;br /&gt;
[https://www.fastmail.com/cgi-bin/sievetest.pl Filter tester]&lt;br /&gt;
[https://www.fastmail.com/help/technical/sieve-faq.html Small FAQ]&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=120</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=120"/>
		<updated>2020-03-05T07:51:13Z</updated>

		<summary type="html">&lt;p&gt;Göran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Work in progress.....&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved dovecot-lmtpd&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf (uncomment/edit as below)&lt;br /&gt;
 service lmtp {&lt;br /&gt;
  unix_listener /var/spool/postfix/private/dovecot-lmtp {&lt;br /&gt;
   group = postfix&lt;br /&gt;
   mode = 0600&lt;br /&gt;
   user = postfix&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf and change the &amp;quot;mail_location&amp;quot; parameter&lt;br /&gt;
 mail_location = maildir:/var/opi/mail/data/&#039;&#039;&#039;%n&#039;&#039;&#039;/mail &lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%n/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%n/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix/main.cf and at the end add the line&lt;br /&gt;
 virtual_transport = lmtp:unix:private/dovecot-lmtp&lt;br /&gt;
&lt;br /&gt;
Restart services&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
=== Global filtering ===&lt;br /&gt;
If you want to have filters that are executed for all users try the following&lt;br /&gt;
&lt;br /&gt;
Create a location for global scripts&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d&lt;br /&gt;
To be able to run then before and/or after user&#039;s personal filters create additional folders&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/before&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Create scritps in the sieve.d folder, this is a filter for mail marked as spam by spamassasin&lt;br /&gt;
Create /etc/kinguard/sieve.d/junk.sieve&lt;br /&gt;
 require [&amp;quot;fileinto&amp;quot;, &amp;quot;mailbox&amp;quot;];&lt;br /&gt;
 if header :contains &amp;quot;X-Spam-Flag&amp;quot; &amp;quot;YES&amp;quot; {&lt;br /&gt;
    fileinto :create &amp;quot;Junk&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
To run it before the users filters&lt;br /&gt;
 ln -s /etc/kinguard/sieve.d/junk.sieve /etc/kinguard/sieve.d/before/10-junk.sieve&lt;br /&gt;
&lt;br /&gt;
Add the locations to /etc/dovecot/conf.d/90-sieve.conf&lt;br /&gt;
  sieve_before = /etc/kinguard/sieve.d/before&lt;br /&gt;
  sieve_after = /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Restart dovecot&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
To get some additional information on what is going on, enable mail_debug in /etc/dovecot/conf.d/10-logging.conf&lt;br /&gt;
 mail_debug = yes&lt;br /&gt;
Monitor the tail -f /var/log/mail.log file is your friend here.&lt;br /&gt;
=== Exemple Filters ===&lt;br /&gt;
[https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples Examples]&lt;br /&gt;
&lt;br /&gt;
=== Useful links ===&lt;br /&gt;
[https://www.fastmail.com/cgi-bin/sievetest.pl Filter tester]&lt;br /&gt;
[https://www.fastmail.com/help/technical/sieve-faq.html Small FAQ]&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=119</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=119"/>
		<updated>2020-03-05T07:48:27Z</updated>

		<summary type="html">&lt;p&gt;Göran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Work in progress.....&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved dovecot-lmtpd&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf (uncomment/edit as below)&lt;br /&gt;
 service lmtp {&lt;br /&gt;
  unix_listener /var/spool/postfix/private/dovecot-lmtp {&lt;br /&gt;
   group = postfix&lt;br /&gt;
   mode = 0600&lt;br /&gt;
   user = postfix&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf and change the &amp;quot;mail_location&amp;quot; parameter&lt;br /&gt;
 mail_location = maildir:/var/opi/mail/data/&#039;&#039;&#039;%n&#039;&#039;&#039;/mail &lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%n/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%n/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix/main.cf and at the end add the line&lt;br /&gt;
 virtual_transport = lmtp:unix:private/dovecot-lmtp&lt;br /&gt;
&lt;br /&gt;
Restart services&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
=== Global filtering ===&lt;br /&gt;
If you want to have filters that are executed for all users try the following&lt;br /&gt;
&lt;br /&gt;
Create a location for global scripts&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d&lt;br /&gt;
To be able to run then before and/or after user&#039;s personal filters create additional folders&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/before&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Create scritps in the sieve.d folder, this is a filter for mail marked as spam by spamassasin&lt;br /&gt;
Create /etc/kinguard/sieve.d/junk.sieve&lt;br /&gt;
 require [&amp;quot;fileinto&amp;quot;, &amp;quot;mailbox&amp;quot;];&lt;br /&gt;
 if header :contains &amp;quot;X-Spam-Flag&amp;quot; &amp;quot;YES&amp;quot; {&lt;br /&gt;
    fileinto :create &amp;quot;Junk&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
To run it before the users filters&lt;br /&gt;
 ln -s /etc/kinguard/sieve.d/junk.sieve /etc/kinguard/sieve.d/before/10-junk.sieve&lt;br /&gt;
&lt;br /&gt;
Add the locations to /etc/dovecot/conf.d/90-sieve.conf&lt;br /&gt;
  sieve_before = /etc/kinguard/sieve.d/before&lt;br /&gt;
  sieve_after = /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Restart dovecot&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Exemple Filters ===&lt;br /&gt;
[https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples Examples]&lt;br /&gt;
&lt;br /&gt;
=== Useful links ===&lt;br /&gt;
[https://www.fastmail.com/cgi-bin/sievetest.pl Filter tester]&lt;br /&gt;
[https://www.fastmail.com/help/technical/sieve-faq.html Small FAQ]&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=118</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=118"/>
		<updated>2020-03-05T07:47:23Z</updated>

		<summary type="html">&lt;p&gt;Göran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Work in progress.....&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved dovecot-lmtpd&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf (uncomment/edit as below)&lt;br /&gt;
 service lmtp {&lt;br /&gt;
  unix_listener /var/spool/postfix/private/dovecot-lmtp {&lt;br /&gt;
   group = postfix&lt;br /&gt;
   mode = 0600&lt;br /&gt;
   user = postfix&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf and change the &amp;quot;mail_location&amp;quot; parameter&lt;br /&gt;
 mail_location = maildir:/var/opi/mail/data/&#039;&#039;&#039;%n&#039;&#039;&#039;/mail &lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%{auth_username}/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%{auth_username}/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix/main.cf and at the end add the line&lt;br /&gt;
 virtual_transport = lmtp:unix:private/dovecot-lmtp&lt;br /&gt;
&lt;br /&gt;
Restart services&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
=== Global filtering ===&lt;br /&gt;
If you want to have filters that are executed for all users try the following&lt;br /&gt;
&lt;br /&gt;
Create a location for global scripts&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d&lt;br /&gt;
To be able to run then before and/or after user&#039;s personal filters create additional folders&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/before&lt;br /&gt;
 mkdir /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Create scritps in the sieve.d folder, this is a filter for mail marked as spam by spamassasin&lt;br /&gt;
Create /etc/kinguard/sieve.d/junk.sieve&lt;br /&gt;
 require [&amp;quot;fileinto&amp;quot;, &amp;quot;mailbox&amp;quot;];&lt;br /&gt;
 if header :contains &amp;quot;X-Spam-Flag&amp;quot; &amp;quot;YES&amp;quot; {&lt;br /&gt;
    fileinto :create &amp;quot;Junk&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
To run it before the users filters&lt;br /&gt;
 ln -s /etc/kinguard/sieve.d/junk.sieve /etc/kinguard/sieve.d/before/10-junk.sieve&lt;br /&gt;
&lt;br /&gt;
Add the locations to /etc/dovecot/conf.d/90-sieve.conf&lt;br /&gt;
  sieve_before = /etc/kinguard/sieve.d/before&lt;br /&gt;
  sieve_after = /etc/kinguard/sieve.d/after&lt;br /&gt;
&lt;br /&gt;
Restart dovecot&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Exemple Filters ===&lt;br /&gt;
[https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples Examples]&lt;br /&gt;
&lt;br /&gt;
=== Useful links ===&lt;br /&gt;
[https://www.fastmail.com/cgi-bin/sievetest.pl Filter tester]&lt;br /&gt;
[https://www.fastmail.com/help/technical/sieve-faq.html Small FAQ]&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=117</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=117"/>
		<updated>2020-03-05T07:25:10Z</updated>

		<summary type="html">&lt;p&gt;Göran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Work in progress.....&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved dovecot-lmtpd&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf (uncomment/edit as below)&lt;br /&gt;
 service lmtp {&lt;br /&gt;
  unix_listener /var/spool/postfix/private/dovecot-lmtp {&lt;br /&gt;
   group = postfix&lt;br /&gt;
   mode = 0600&lt;br /&gt;
   user = postfix&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf and change the &amp;quot;mail_location&amp;quot; parameter&lt;br /&gt;
 mail_location = maildir:/var/opi/mail/data/&#039;&#039;&#039;%n&#039;&#039;&#039;/mail &lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%{auth_username}/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%{auth_username}/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix/main.cf and at the end add the line&lt;br /&gt;
 virtual_transport = lmtp:unix:private/dovecot-lmtp&lt;br /&gt;
&lt;br /&gt;
Restart services&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
=== Exemple Filters ===&lt;br /&gt;
[https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples Examples]&lt;br /&gt;
&lt;br /&gt;
=== Useful links ===&lt;br /&gt;
[https://www.fastmail.com/cgi-bin/sievetest.pl Filter tester]&lt;br /&gt;
[https://www.fastmail.com/help/technical/sieve-faq.html Small FAQ]&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=116</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=116"/>
		<updated>2020-03-04T06:42:05Z</updated>

		<summary type="html">&lt;p&gt;Göran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Work in progress.....&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved dovecot-lmtpd&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf (uncomment/edit as below)&lt;br /&gt;
 service lmtp {&lt;br /&gt;
  unix_listener /var/spool/postfix/private/dovecot-lmtp {&lt;br /&gt;
   group = postfix&lt;br /&gt;
   mode = 0600&lt;br /&gt;
   user = postfix&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%{auth_username}/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%{auth_username}/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix/main.cf and at the end add the line&lt;br /&gt;
 virtual_transport = lmtp:unix:private/dovecot-lmtp&lt;br /&gt;
&lt;br /&gt;
Restart services&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
=== Exemple Filters ===&lt;br /&gt;
[https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples Examples]&lt;br /&gt;
&lt;br /&gt;
=== Useful links ===&lt;br /&gt;
[https://www.fastmail.com/cgi-bin/sievetest.pl Filter tester]&lt;br /&gt;
[https://www.fastmail.com/help/technical/sieve-faq.html Small FAQ]&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=115</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=115"/>
		<updated>2020-03-03T14:14:38Z</updated>

		<summary type="html">&lt;p&gt;Göran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Work in progress.....&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved dovecot-lmtpd&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf (uncomment/edit as below)&lt;br /&gt;
 service lmtp {&lt;br /&gt;
  unix_listener /var/spool/postfix/private/dovecot-lmtp {&lt;br /&gt;
   group = postfix&lt;br /&gt;
   mode = 0600&lt;br /&gt;
   user = postfix&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%{auth_username}/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%{auth_username}/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix/main.cf and at the end add the line&lt;br /&gt;
 virtual_transport = lmtp:unix:private/dovecot-lmtp&lt;br /&gt;
&lt;br /&gt;
Restart services&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
=== Exemple Filters ===&lt;br /&gt;
[https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples Examples]&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=114</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=114"/>
		<updated>2020-03-03T13:48:36Z</updated>

		<summary type="html">&lt;p&gt;Göran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Work in progress.....&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved dovecot-lmtpd&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf (uncomment/edit as below)&lt;br /&gt;
 service lmtp {&lt;br /&gt;
  unix_listener /var/spool/postfix/private/dovecot-lmtp {&lt;br /&gt;
   group = postfix&lt;br /&gt;
   mode = 0600&lt;br /&gt;
   user = postfix&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%{auth_username}/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%{auth_username}/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix/main.cf and at the end add the line&lt;br /&gt;
 virtual_transport = lmtp:unix:private/dovecot-lmtp&lt;br /&gt;
&lt;br /&gt;
Restart services&lt;br /&gt;
 systemctl restart dovecot&lt;br /&gt;
 systemctl restart postfix&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=113</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=113"/>
		<updated>2020-03-03T13:08:45Z</updated>

		<summary type="html">&lt;p&gt;Göran: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Work in progress.....&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/10-master.conf (uncomment/edit as below)&lt;br /&gt;
 service lmtp {&lt;br /&gt;
  unix_listener /var/spool/postfix/private/dovecot-lmtp {&lt;br /&gt;
   group = postfix&lt;br /&gt;
   mode = 0600&lt;br /&gt;
   user = postfix&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%{auth_username}/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%{auth_username}/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Restart dovecot&lt;br /&gt;
 systemctl restart dovecot&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=112</id>
		<title>MailFilter</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=MailFilter&amp;diff=112"/>
		<updated>2020-03-03T13:05:01Z</updated>

		<summary type="html">&lt;p&gt;Göran: Created page with &amp;quot;&amp;#039;&amp;#039;&amp;#039;Work in progress.....&amp;#039;&amp;#039;&amp;#039;  == Mail and Spam filtering using the Kinguard Project Installation. ==  Today a lot of mail that comes into a mailbox is in dire need of filtering...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Work in progress.....&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail and Spam filtering using the Kinguard Project Installation. ==&lt;br /&gt;
&lt;br /&gt;
Today a lot of mail that comes into a mailbox is in dire need of filtering. This can be due to spam or just having multiple email addresses landing in the same account that needs to be sorted in different folders depending on the receiver address.&lt;br /&gt;
&lt;br /&gt;
This is work in progress trying to add this functionality to the Kinguard Project software.&lt;br /&gt;
&lt;br /&gt;
=== Step one: Add spam detection ===&lt;br /&gt;
[https://spamassassin.apache.org/ Spamassassin] is a software very commonly used to detect spam. Using [[Access your unit using SSH|ssh]] to log in to your device it can be installed by:&lt;br /&gt;
&lt;br /&gt;
 apt update&lt;br /&gt;
 apt install spamassasin&lt;br /&gt;
&lt;br /&gt;
Edit /etc/postfix.cf, under the smtp line (~line 12) add &amp;quot;-o content_filter=spamassasin&amp;quot; as below&lt;br /&gt;
 smtp      inet  n       -       y       -       -       smtpd&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
Next in the same file under the &amp;quot;submission&amp;quot; add the same line:&lt;br /&gt;
 submission inet n       -       -       -       -       smtpd&lt;br /&gt;
   -o syslog_name=postfix/submission&lt;br /&gt;
   -o smtpd_tls_security_level=encrypt&lt;br /&gt;
   -o smtpd_relay_restrictions=permit_sasl_authenticated,reject&lt;br /&gt;
   -o content_filter=spamassassin&lt;br /&gt;
&lt;br /&gt;
Restart postfix&lt;br /&gt;
 systemctl restart postfix&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
=== Step two: Mail filtering ===&lt;br /&gt;
Dovecot is already setup on the device and we need to add support for Seive. This is done uing [https://pigeonhole.dovecot.org/ Pigeonhole] (the name is very good, well worth reading the leading paragraph on the project page). &lt;br /&gt;
This is installed by:&lt;br /&gt;
 apt install dovecot-sieve dovecot-managesieved&lt;br /&gt;
&lt;br /&gt;
Edit the file /etc/dovecot/conf.d/90-sieve.conf, commenting out the existing sieve line&lt;br /&gt;
  # sieve = file:~/sieve;active=~/.dovecot.sieve&lt;br /&gt;
  sieve = /var/opi/mail/data/%{auth_username}/sieve/dovecot.sieve&lt;br /&gt;
  sieve_dir = /var/opi/mail/data/%{auth_username}/sieve&lt;br /&gt;
&lt;br /&gt;
Edit /etc/dovecot/conf.d/20-managesieve.conf, enable services below by uncommenting them.&lt;br /&gt;
&lt;br /&gt;
 service managesieve-login {&lt;br /&gt;
  inet_listener sieve {&lt;br /&gt;
    port = 4190&lt;br /&gt;
  }&lt;br /&gt;
  inet_listener sieve_deprecated {&lt;br /&gt;
    port = 2000&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  # Number of connections to handle before starting a new process. Typically&lt;br /&gt;
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0&lt;br /&gt;
  # is faster. &amp;lt;doc/wiki/LoginProcess.txt&amp;gt;&lt;br /&gt;
  service_count = 1&lt;br /&gt;
 &lt;br /&gt;
  # Number of processes to always keep waiting for more connections.&lt;br /&gt;
  process_min_avail = 0&lt;br /&gt;
 &lt;br /&gt;
  # If you set service_count=0, you probably need to grow this.&lt;br /&gt;
  vsz_limit = 64M&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 service managesieve {&lt;br /&gt;
  # Max. number of ManageSieve processes (connections)&lt;br /&gt;
  process_limit = 1024&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Create /etc/dovecot/conf.d/20-lmtp.conf&lt;br /&gt;
 protocol lmtp {&lt;br /&gt;
  postmaster_address = admin@localhost&lt;br /&gt;
  mail_plugins = $mail_plugins sieve&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Edit /usr/share/roundcube/config/config.inc.php&lt;br /&gt;
 $config[&#039;plugins&#039;] = array(&lt;br /&gt;
    &#039;archive&#039;,&lt;br /&gt;
    &#039;opi_addressbook&#039;,&lt;br /&gt;
    &#039;opi_identities&#039;,&lt;br /&gt;
    &#039;zipdownload&#039;,&lt;br /&gt;
    &#039;managesieve&#039;,&lt;br /&gt;
 );&lt;br /&gt;
and adding to the same file&lt;br /&gt;
 $config[&#039;managesieve_host&#039;] = &#039;localhost&#039;;&lt;br /&gt;
&lt;br /&gt;
Restart dovecot&lt;br /&gt;
 systemctl restart dovecot&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
	<entry>
		<id>https://www.kinguardproject.org/wiki/index.php?title=Tutorials_and_How-tos&amp;diff=111</id>
		<title>Tutorials and How-tos</title>
		<link rel="alternate" type="text/html" href="https://www.kinguardproject.org/wiki/index.php?title=Tutorials_and_How-tos&amp;diff=111"/>
		<updated>2020-03-03T07:13:07Z</updated>

		<summary type="html">&lt;p&gt;Göran: Adding section about mail and spam filtering&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Beginner ==&lt;br /&gt;
&lt;br /&gt;
* [[Access your unit using SSH]]&lt;br /&gt;
* [[SSH access using private/public key pair]]&lt;br /&gt;
* [[Run a backup manually]]&lt;br /&gt;
* [[DavDroid Crashes when adding a nextcloud account]]&lt;br /&gt;
&lt;br /&gt;
== Intermediate ==&lt;br /&gt;
* [https://www.kinguardproject.org/forum/viewtopic.php?f=345&amp;amp;t=750/ Change to a larger SD card on OPI]&lt;br /&gt;
* [[Enable serial console]]&lt;br /&gt;
* [[OPIForceReinstall|Reinstall dead OPI]]&lt;br /&gt;
* [[MailFilter|Mail and Spam filtering]]&lt;/div&gt;</summary>
		<author><name>Göran</name></author>
	</entry>
</feed>