vanutsteen.nl => nerds only A blog on rails, php, computing, my bass guitar and stuff

Battling spam

on in Linux, Other

We got a lot of complaints about legitimate mails being marked as spam and therefore not being delivered to our customers.  As a solution I wanted the mails to be delivered to the user’s .SPAM folder.

These is the configuration I decided on:

/etc/amavis/conf.d/20-debian_defaults:

1
$final_spam_destiny       = D_PASS;
/etc/maildroprc:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Global maildrop filter file

# Uncomment this line to make maildrop default to ~/Maildir for
# delivery- this is where courier-imap (amongst others) will look.
DEFAULT="$HOME/Maildir"
SHELL="/bin/bash"
MAILDIRMAKE=`which maildirmake`
logfile "/var/log/maildrop.log"

`test -d $HOME/Maildir/.SPAM`
if ( $RETURNCODE == 1 )
{
`$MAILDIRMAKE -f SPAM $HOME/Maildir`
`echo INBOX.SPAM >> $HOME/Maildir/courierimapsubscribed`
}

if ( /^X-Spam-Status: Yes/ )
{
to "$HOME/Maildir/.SPAM/"
}
/etc/roundcube-webmail/main.inc.php:
1
2
3
4
5
6
7
<?php
// store spam messages in this mailbox
$rcmail_config['junk_mbox'] = 'SPAM';

// display these folders separately in the mailbox list.
// these folders will automatically be created if they do not exist
$rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'SPAM', 'Trash');
Delete all the old Junk-folders:
1
2
rm -r /home/*/Maildir/.Junk
rm -r /home/*/homes/*/Maildir/.Junk

To make it extra nice:

/etc/amavis/conf.d/50-user:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use strict;

#
# Place your configuration directives here.  They will override those in
# earlier files.
#
# See /usr/share/doc/amavisd-new/ for documentation and examples of
# the directives you can use in this file
#

#$log_level = 5;

$pax='pax';

read_hash(\%whitelist_sender, '/etc/amavis/whitelist');
read_hash(\%blacklist_sender, '/etc/amavis/blacklist');
read_hash(\%spam_lovers, '/etc/amavis/spam_lovers');

@bypass_spam_checks_maps = (
\%bypass_spam_checks, \@bypass_spam_checks_acl, \$bypass_spam_checks_re);

#------------ Do not modify anything below this line -------------
1;  # ensure a defined return

And:

/etc/amavis/conf.d/50-user:
1
2
3
touch /etc/amavis/whitelist
touch /etc/amavis/blacklist
touch /etc/amavis/spam_lovers

1
2
          </div>
        </figure>

And restart amavis:

/etc/amavis/conf.d/50-user:
1
/etc/init.d/amavis restart

1
2
          </div>
        </figure>

Comments