Configure Zentyal 4.2 To Move SPAM Email To Junk Folder

Zentyal, the “all-in-one” exchange server replacement and does quite a good job delivering AD-like management and authentication, file shares, email and webmail straight out of the box. The out-of-the-box set-up is a good starting point and most people will be up and running in no time.

Once you start to dig a little deeper into Zentyal’s configuration, and start to use it day-to-day, you’ll notice that a few basic things are missing.

Take for example the email offering – it all works quite nicely until you start to receive SPAM. You may, as I did, enable the email filter ‘Antispam’ to help fight your SPAM problems. The interesting thing with Zentyal is that enabling all of this will enable you to mark messages as SPAM, but not do anything with it. So now all of your users will still have all their messages in their Inbox, just some will have a SPAM rating in their header.

What you really need is to have Zentyal move all of the SPAM marked messages into a Junk folder (which is actually created for all users by default). To do that you’ll need to create your own Sieve rules configuration to move any received email message to the Junk folder. It’s easy enough to do, with just a few small configuration file changes.

Log onto your Zentyal server using a Terminal and open the dovecot.conf configuration file using your favourite file editor.

1

vi/etc/dovecot/dovecot.conf

Add the following code in the ## Plugin settings section at the bottom of the file:

1

2

3

4

5

6

plugin{

sieve=~/.dovecot.sieve

sieve_global_path=/etc/dovecot/sieve/default.sieve

sieve_dir=~/sieve

sieve_global_dir=/etc/dovecot/sieve/global/

}

Create the global directory, if it doesn’t already exist:

1

mkdir-p/etc/dovecot/sieve/global

And add your Sieve rule file to move all incoming email into the Spam/ Junk folder which has the X-Spam-Flag set by SpamAssassin:

1

2

3

4

5

require["fileinto"];

# rule:[SPAM]

ifheader:contains"X-Spam-Flag""YES"{

fileinto"Spam";

}

Finally you’ll need to restart dovecot for the changes to be picked up.

1

service dovecot restart

And that’s all there is too it. All new SPAM mail will be moved directly into the Spam/ Junk folder.