Divert spam into individual folders

From Kolab wiki

(Redirected from Divert spam into a folder)
Jump to: navigation, search

Contents

Step 1 - Configure amavis to divert spam

Edit amavisd.conf.template, and uncomment or modify it to get:

...
$final_spam_destiny    = D_PASS;
...
$addr_extension_spam   = 'spam'; 
...
$recipient_delimiter = '+';

On original kolab system, only addr_extension_spam need to be modified.
Don't forget to run kolabconf to activate the changes.

That way any spam will be redirected to address "user+spam@domain". This notation is the plus addressing that most mail server will understant as deliver this mail into the sub-folder 'spam' of the user user@domain INBOX .

If the user don't have such folder, the mail will go as usual in the INBOX.

Step2 - Create the 'spam' folder

Each user can create a folder 'spam' in its INBOX.
Cyrus require to give the 'p' right to user 'anyone' on this folder to authorize plus addressing.
If the user is not able to change ACL's itself on this mailbox, then you (the manager) must do it for him!

Step3 - Cleanup old spam

You can set the number of day after which messages will be expired on each folder individually.
You can set the "expire" property using the cyradm tools.
Once a day (this is configurable in cyrus.conf) cyrus run cyr_expire that will purge any expired emails.

You can also use the ipurge command tools to cleanup expired emails (or email with an excessive size).

Step4 - Use some scripting

If you don't want to do this manually for each user, then use some scripting!

create the file create_spam_folder.sh

DOMAIN=example.com
FOLDER=spam
for user in $* ; do
   echo createmailbox user/$user/$SPAM@$DOMAIN
   echo sam user/$user/$SPAM@example.com anyone p
   echo mboxcfg user/$user/$SPAM@$DOMAIN
done | cyradm -u manager localhost

use it tis way

# sh create_spam_folder.sh john.smith paul george ringo

The script will ask you for the manager password and then create the 'spam' folder for the 4 users john.smith, paul, george and ringo

Personal tools