Current time: 11-25-2024, 04:15 PM Hello There, Guest! (LoginRegister)


Post Reply 
Mailbox Spam Folder / Spam Training / Spam Filter / Mark as Junk
Author Message
NewtonPasqualini Offline


Posts: 3
Joined: Oct 2011
Reputation: 0
Post: #1
Wink Mailbox Spam Folder / Spam Training / Spam Filter / Mark as Junk
Hi there Cool!

So it is a How To make it all together with the STOCK ispCP 1.0.6

I did not update to 1.0.7 yet by problems in ispCP 1.0.7 over RHEL 5 setup.

So, I am using CentOS 5.8, be sure to have installed RPMForge Repo.

First of all, install maildrop, we need to replace the virtual_transport at postfix from virtual to maildrop!

Portfix "virtual" process donnot support filters, thats why we are moving to maildrop virtual transport.

To install maildrop, first of all do:
Code:
yum install -y pcre pcre-devel

After that, download maildrop at:
http://sourceforge.net/projects/courier/...2/download

then:
Code:
tar xjvf maildrop*
cd maildrop-2.5.5
./configure --prefix=/usr
make
make install-strip
make install-man
chown root:mail /usr/bin/maildrop
chmod +s /usr/bin/maildrop

Create the file /etc/maildroprc with the contents:
Code:
# commands and variables for making the mail directories
maildirmake=/usr/lib/courier-imap/bin/maildirmake
mkdir=/bin/mkdir
rmdir=/bin/rmdir
MAILDIR=$DEFAULT

# make the user's mail directory if it doesn't exist
`test -e $MAILDIR`
if ($RETURNCODE != 0)
{
`$mkdir -p $MAILDIR`
`$rmdir $MAILDIR`
`$maildirmake $MAILDIR`
}

# make the .Junk folder if it doesn't exist
JUNK_FOLDER=.Junk
_JUNK_DEST=$MAILDIR/$JUNK_FOLDER/
`test -d $_JUNK_DEST`
if ($RETURNCODE != 0 )
{
`$maildirmake $_JUNK_DEST`
#auto subscribe. the following works for courier-imap
`echo INBOX.Junk >> $MAILDIR/courierimapsubscribed`
}

if (/^X-Spam-Flag:.*YES/)
{
    exception {
        to $DEFAULT/.Junk/
    }
}

All done with maildrop!

Now you should take Amavis-New, Clamav and SpamAssassin running.

Just update the virus database before running:
Code:
freshclam

Code:
service spamassassin start
service clamd start
service amavisd start

To run amavis and spamassassin in postfix check in the /etc/postfix/master.cf if this exists:
Code:
amavis unix    -       -       n        -      2     lmtp
    -o lmtp_data_done_timeout=1200
    -o lmtp_send_xforward_command=yes
    -o disable_dns_lookups=yes
    -o max_use=20

localhost:10025 inet n    -       n       -       -     smtpd
    -o content_filter=
    -o smtpd_delay_reject=no
    -o smtpd_client_restrictions=permit_mynetworks,reject
    -o smtpd_helo_restrictions=
    -o smtpd_sender_restrictions=
    -o smtpd_recipient_restrictions=permit_mynetworks,reject
    -o smtpd_data_restrictions=reject_unauth_pipelining
    -o smtpd_end_of_data_restrictions=
    -o smtpd_restriction_classes=
    -o mynetworks=127.0.0.0/8
    -o smtpd_error_sleep_time=0
    -o smtpd_soft_error_limit=1001
    -o smtpd_hard_error_limit=1000
    -o smtpd_client_connection_count_limit=0
    -o smtpd_client_connection_rate_limit=0
    -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks,no_mi​lters,no_address_mappings
    -o local_header_rewrite_clients=
    -o smtpd_milters=
    -o local_recipient_maps=
    -o relay_recipient_maps=

So you need this in /etc/postfix/master.cf if you donnot have yet.

Again you need amavis as your mailfilter to score and tag the spam/virus messages, check now at /etc/postfix/main.cf:
Code:
content_filter               = amavis:[127.0.0.1]:10024
If not present, insert there in a new line.

Remove the "virtual_transport" directive at /etc/postfix/main.cf and place this:
Code:
maildrop_destination_recipient_limit = 1
virtual_transport            = maildrop

Ok, now you can restart postfix process:
Code:
service postfix restart

All done!

If you are using "Roundcube Webmail", there is a plugin named "markasjunk", enable that plugin and setup SpamAssassin Bayes.

First create some cronjobs like:
Code:
0 */1 * * * /usr/bin/sa-learn --ham /var/mail/virtual/*/*/cur/* &> /dev/null
0 */1 * * * /usr/bin/sa-learn --ham /var/mail/virtual/*/*/.Sent/cur/* &> /dev/null
0 */1 * * * /usr/bin/sa-learn --spam /var/mail/virtual/*/*/.Junk/cur/* &> /dev/null

Then add to your /etc/mail/spamassassin/local.cf:
Code:
use_bayes               1
bayes_auto_learn                        1
bayes_auto_learn_threshold_nonspam      0.1
bayes_auto_learn_threshold_spam         5.0
use_auto_whitelist                      1

Now you have a strong SPAM filter that learn what is SPAM with user reports!!!
04-13-2012 06:11 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)