Configure Zentyal 4.2 To Move SPAM Email To Junk Folder

Configure Zentyal 4.2 To Move SPAM Email To Junk Folder

Get Social!

logo-zentyal-blackZentyal, 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.

vi /etc/dovecot/dovecot.conf

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

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:

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:

require ["fileinto"];
# rule:[SPAM]
if header :contains "X-Spam-Flag" "YES" {
        fileinto "Spam";
}

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

service dovecot restart

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


5 Comments

Hans Hussem

26-Apr-2016 at 1:30 pm

The dovecot.conf has a pluginn section at the bottom. This reads as follows:
##
## Plugin settings
##
plugin {
quota = maildir:User quota
quota_rule = *:storage=0
sieve = /var/vmail/%Ld/%Ln/sieve-script
sieve_global_path = /var/vmail/default.sieve
sieve_storage = /var/vmail/%Ld/%Ln
sieve_dir = /var/vmail/%Ld/%Ln
}

I assume the /var/mail/sieve directory is where I should put the script, correct?
Anything else I need to know. Name/extention of script file?
Please advice. Thank you very much.
Hans

Sergio

4-Aug-2016 at 4:46 pm

You can’t really do this editing /etc/dovecot/dovecot.conf, because this is a file auto created by ebox when you restart dovecot it will reset the config file to the original settings. So, you have to edit the /usr/share/zentyal/stubs/mail/dovecot.conf.mas which is the file that is used to create the dovecot.conf file.

happnatious1

27-Sep-2016 at 4:47 pm

restarting service dovecot didn’t overwrite the dovecot.conf file, but restarting zentyal did. Editing the dovecot.conf.mas file worked and survives a reboot however, spam is still going to my inbox.

happnatious1

28-Sep-2016 at 3:01 am

raystime.blogspot.com/2016/02/installing-and-configuring-zentyal

at the bottom of the page is a solution that works.

some1

26-May-2017 at 9:06 pm

Can someone share the fix? my spam is still not being send to the spam folder.

Leave a Reply to happnatious1 Cancel reply

Visit our advertisers

Quick Poll

Do you use ZFS on Linux?

Visit our advertisers