Filtering Emails on the Server

From Kolab Wiki

Jump to: navigation, search

You can use Sieve to do so.

Contents


How to set a Sieve Script for another user as administrator?

One way to do this is using sieveshell. Note that sieveshell will use an unencrypted connection, so it is wise to do this from the server machine itself or over an encrypted network connection.

/kolab/bin/sieveshell --user=a.user@example.org --authname=manager  localhost


After giving the manager password, you can upload and activate a script. Here is a set of commands (use help for a short explanation):

list
put example.siv
activate example.siv
list
quit


Here is an example script (note that Umlauts should be encoded as utf8):

# Example Sieve script which does both
# a) vacation and
# b) email delivery into a subfolder when no scheduling mail
#
require "vacation";
require "fileinto";
 
if allof (not header :contains "X-Spam-Flag" "YES",
       # only react to emails coming from a specific domain:
       address :domain :contains "From" "example.com" ) {
    vacation :addresses [ "usera@example.com", "mr.a@example.org" ] :days 7 text:
Out of the office, I am, until August the 28th, 2006.
 
In urgent cases please contact: <my replacement>
 
E-Mail: <email address of vacation replacement>
Telefon: +49 000000 00
Fax:  +49 00000000 00

Best Regards,
-- <enter your name and email address here>
.
;
}

if header :contains ["X-Kolab-Scheduling-Message"] ["FALSE"] {
    fileinto "INBOX/incoming";
}
#
if header :contains ["List-Id"] ["freegis-list.intevation.de"] {
    fileinto "INBOX/ml/freegis";
    stop;
}


Using Smartsieve for editing Sievescripts

An other way to edit sieve scripts are smartsieve which you can download from [1].

Installation

cd /kolab/var/kolab/www
wget http://mesh.dl.sourceforge.net/sourceforge/smartsieve/smartsieve-1.0-RC2.tar.gz
tar xzvf smartsieve-1.0-RC2.tar.gz
rm smartsieve-1.0-RC2.tar.gz
mv smartsieve-1.0-RC2 smartsieve
cd smartsieve/conf
vi servers.php

Edit here the first server entry, the default options would work.

vi config.php

Here I had set the option $default->user_select_server to false. So the users don't have to join the server

Now smartsieve run, you can log in with your email address and password at https://your.domain/smartsieve

Deinstallation

cd /kolab/var/kolab/www
rm -rf smartsieve

How to provide global default filters

It is possible to provide the users on the Kolab server with a global default filtering script.

1. Upload and activate a script to the "manager" account. (e.g. called default.siv) 2. Use the "include" extension in each user script where you want to include the global script.

Example:

require ["include", ....];
include :global "default.siv";

Global sieve scripts

The only possibility presently to have a global is using the 'include'-directive. So, for Kolab (let's say the User is called 'kro'):

  • Enter the user's sieve directory: cd /kolab/var/imapd/sieve/domain/x/x.your.domain.tld/k/kro
  • Edit your default-sieve-Script for that user (do not forget to 'require' include), no need to use filename.bc:
vim default
require "fileinto";
require "...your other requires...";
require "include";
include :global "default";
  • compile it to bytecode:
sievec default default.bc
  • Change to global, edit, compile global sieve script:
cd /kolab/var/imapd/sieve/global/
vim default
(do your sieve-ing...)
  • compile this to bytecode, too:
sievec default default.bc

Deficiencies / Drawbacks

The deficiencies of this method are that

* this include has to be in every user's defualt sieve script, and
* users could edit their sieve scripts to not execute the 'global' sieve script by removing the reference to :global.

Sieve scripts for shared folders

If you want your shared folders to have sieve script, you need to use the command line to install them. The process is quite straight forward, though:

  • Create the sieve script with the editor of your choice (or even copy paste it from horde)
  • Upload it as manager:
sieveshell --user=manager --authname=manager localhost
Enter YourPassword
put YourScriptsName
quit

Now you can set it with the cyradm tool:

cyradm --user manager localhost
Enter YourPassword
mboxcfg shared.SomeFolder sieve YourScriptsName
quit
  • You can check the sieve script of a folder with
info shared.SomeFolder
  • Please note that cyradm understands wildcards, so you can use something like
mboxcfg shared.* sieve YourScriptsName

to set a script for all shared folders at once.

See also

Personal tools