Zentyal Forum, Linux Small Business Server

Zentyal Server => Email and Groupware => Topic started by: tokerau on April 21, 2016, 07:34:28 am

Title: Sieve configuration information needed.
Post by: tokerau on April 21, 2016, 07:34:28 am
This is the first time I've worked with sieve. I have installed Zentyal 4.2 successfully, and now I want to configure the spam filters. I am somewhat new to linux, and quite new to email servers.
I have done some reading on how to set up sieve, and there are many examples of the plugin in the dovecot.conf file, and I can do that. Then there are examples of simple filter scripts that move tagged messages into the Spam directory. There are two things that they don't seem to articulate:
1. These scripts are just files, correct? Is there a certain naming convention that I should follow?
2. I don't know where to put the filter scripts files so sieve can find and execute them. Where should they be stored? Once they are stored in the right place, is there something to make sieve know they are there?
Thanks for any help you can give.
Title: [SOLVED] Sieve configuration information needed.
Post by: tokerau on May 06, 2016, 09:43:27 pm
I see that no one responded. After a lot of research and testing this is what I've learned:

the plugin settings are contained in /etc/dovecot/dovecot.conf

However, those are generated by Zentyal, so any changes you make in that file may go away next time Zentyal updates the settings. So you have to put the settings in the templace file which is located here:


It's a bit tricky to find the spot in the file because it is just the template.
Here is what I did:

## Plugin settings
plugin {
  quota = maildir:User quota
  quota_rule = *:storage=0

  sieve = /var/vmail/%Ld/%Ln/user.sieve
  sieve_global_path = /var/vmail/default.sieve
  sieve_storage = /var/vmail/%Ld/%Ln
  sieve_dir     = /var/vmail/%Ld/%Ln
  sieve_before = /var/vmail/default.sieve
  sieve_after = /var/vmail/%Ld/%Ln/user.sieve

Here is what it means:

sieve = is the directory where the user sieve script goes. The %Ld and %Ln (correct me on this) seem to be variables that ultimately mean the domain and name of the user.

Sieve_global_path = is the locatino of the global sieve script.
It will be executed only if there aren't any user scripts. Once you create a script for an individual user, the global script will no longer be executed for that user.

I don't know what the storage and dir settings mean.

A word about scripts before I finish with the settings: The scripts need to have the name .sieve to be found. I named mine default.sieve and user.sieve. When they are first run they will be compiled. When you change the script, it will need to be recompiled. You can force this by running sievec <script name>.

I have some scripts dealing with spam in the default sieve file. They pertain to all users. However, if you need a
vacation response script, you must do it for the individual user. This, then, disables the global script for that users,
causing the spam scripts to not be run. That is bad. So I discovered that you can set it so that the global is run before any other scripts by using the

sieve_before =

setting. That tells sieve to run that script before any others.

Then the

sieve_after =

setting is set to the location of the user scripts.

I hope this helps other people figure this out.

Title: Re: Sieve configuration information needed.
Post by: igp on June 15, 2016, 03:50:03 am
Log in to the Sogo interface with the appropriate user, select the gear, under the mail options tab at the bottom is a section called filters.  This is a GUI to sieve.
Title: Re: Sieve configuration information needed.
Post by: trysomething on June 15, 2016, 11:34:04 pm
So the original idea of editing the stub file is almost right, but it won't survive an upgrade.  Everything inside /usr/share/Zentyal/stubs is generated by Zentyal and any changes made to those .mas files can be overwritten by updating a module or upgrading Zentyal to a newer version.
You can however make the following 2 folders like:
sudo mkdir -p /etc/Zentyal/stubs
sudo mkdir -p /etc/Zentyal/stubs/mail

Now just copy the stub file that you edited from /usr/share/Zentyal/stubs/mail to /etc/Zentyal/stubs/mail

For those who come across this in the future Zentyal has already set the mail module to look for a script named 'default.sieve' under the directory /var/vmail - so simply using something like:
nano /var/vmail/default.sieve

and then inputting your sieve script there will work without altering a single stub file.  Once you've created the script you would want to restart the mail and openchange modules like:

sudo service Zentyal mail restart
sudo service Zentyal openchange restart

If they both say OK next to them then you're good to go, if one says failed (or both) then you've gotta go dig into your default.sieve to see where things went wrong.