Koozali.org: home of the SME Server

BayesFiltering for SpamAssasin

Offline compdoc

  • ****
  • 211
  • +0/-0
BayesFiltering for SpamAssasin
« Reply #45 on: November 16, 2006, 02:04:26 PM »
yes. These commands are helpful:

config show qpsmtpd
config setprop qpsmtpd DNSBL enabled
config setprop qpsmtpd RHSBL enabled
#to change the DNSBL lists used:
config setprop qpsmtpd RBLList sbl-xbl.spamhaus.org,relays.ordb.org
#after setting any properties, you must run:
signal-event email-update
svc -t /service/qpsmtpd

Dont change the SBLList list used by RHSBL (the one server listed is the only one). I've read the RHSBL isnt as fast or as useful as DNSBL, but you decide...

There's also a white/black list you can modify to specifically allow/block domains, but it can be a lot of work to maintain. You must use caps for the words White and Black:

#adds to list:
db spamassassin setprop wbl.global *informit.com White *gfi.com White

#replaces list:
db spamassassin set wbl.global list *informit.com White *gfi.com White *800-flowers.net White *heartdetectives.com Black

#after making changes you must:
expand-template /etc/mail/spamassassin/local.cf
svc -t /service/spamd

#also handy:
db spamassassin show
config show spamassassin

Offline devtay

  • *
  • 145
  • +0/-0
BayesFiltering for SpamAssasin
« Reply #46 on: November 17, 2006, 05:27:21 PM »
Quote from: "compdoc"

As for Spamfilter-stats-7.pl, did you follow the instructions here:

http://mirror.contribs.org/smeserver/contribs/bread/mailstats/install_howto.txt


Yes, I did follow those instructions. Actually, I used the instructions at http://www.sonoracomm.com/index.php?option=com_content&task=view&id=49&Itemid=32  but they are for the same thing. I had to add to the instructions by chmod'ing both of the perl scrips as well.

I thought I may have missed something, so I used the link you posted and started over. First, I rm'd the files that were originally installed. Second, I checked for my bayes filtering to be enabled and the thresholds to be set. Third, I cd to the directories in the install_howto and wget the files into each of the directories. Fourth, I used the chmod commands on both of the scripts. I then typed LearnAsSpam.pl at the root prompt and it ran. Then, I typed spamfilter-stats-7.pl at the root prompt and nothing happened. I then hit the return key and got the error:
 
Use of uninitialized value in string lt at /usr/bin/spamfilter-stats-7.pl line 222, <> line 1.

This seems like a programming error to me. I recall from some of my programming experience that some languages don't like using variables that are not initialized. Further, it seems the program is going into an indefinite loop. Maybe it has to do with Linux and/or a bad permission I have set on my system. I will be the first to admit that my Linux skills are beginner. That is why I chose to use SME. Any ideas?  :?
You can't stop what's coming. It ain't all waiting on you.

Offline compdoc

  • ****
  • 211
  • +0/-0
BayesFiltering for SpamAssasin
« Reply #47 on: November 17, 2006, 08:58:46 PM »
the file mailstats.cron calls the script spamfilter-stats-7.pl, and passes file names to it to be processed. This is the actual code in mailstats.cron:

perl /usr/bin/spamfilter-stats-7.pl /var/log/qpsmtpd/*.s /var/log/qpsmtpd/current

'/var/log/qpsmtpd/*.s' means all files in the directory ending with .s
and '/var/log/qpsmtpd/current' means the current, live log.

When the current log grows to a certain size, it's renamed with an .s extention and a new log is started. If there was a problem, like a loss of power, the file gets named with a .u and isnt used again. You can delete any .u files, unless you want to keep them for their records.

Anyway, until your server receives enough mail to create a .s file, spamfilter-stats-7.pl  wont be able to report on any. And it quits with an error.

If you want to run the script by hand, paste that code listed above...

Oh, and spamfilter-stats-7.pl runs without enabling bayes and without using the LearnAsSpam.pl script. It can be run on any server, and doesnt depend on those other scripts he wrote.

Offline raem

  • *
  • 3,972
  • +4/-0
BayesFiltering for SpamAssasin
« Reply #48 on: November 18, 2006, 05:28:18 PM »
devtay

> I used the instructions at http://www.sonoracomm.com/index.php?option=com_content&task=view&id=49&Itemid=32  

That how to has all the steps needed, you should have followed it exactly but you didn't, as you introduced other steps of your own creating.


> I had to add to the instructions by chmod'ing both of the perl scrips as well.

You did not need to do that.


> I thought I may have missed something....

There is the problem, if you did all the steps in the how to, then your system is configured and you did not need to do anything else.

You tried running the scripts manully, but that is not what you are supposed to do.
Those scripts get run by cron jobs, the how to steps simply copy those scripts to your server.

You should install the rpm as per the very start of the howto
rpm -Uvh
http://mirror.contribs.org/smeserver/contribs/
michaelw/sme7/smeserver-spamassassin-features-0.0.2-0.noarch.rpm

Manually create the LearnAsSpam folder in your IMAP email client, and then wait 24 hours for the scripts to run etc, you will receive email reports.
...

Offline compdoc

  • ****
  • 211
  • +0/-0
BayesFiltering for SpamAssasin
« Reply #49 on: November 19, 2006, 05:51:03 PM »
If anyone is still using the d_gerst scripts to enable your bayes filtering, you might want to make some changes.

d_gerst created a security risk by placing the bayes token database files in the /etc/mail/spamassassin folder.  The risk comes from anyone changing

permissions on this folder to correct errors in the /var/log/spamd/current log that prevented bayes from working. He should have just used the default

location..

And if you didnt change the permissions, then your bayes filtering isnt working anyway...

If you still want to use d_gerst's bayes_filter.sh script, you have to make changes in it to correct the paths. If interested, I'll post what you need

to do...

The following isnt a script. Sorry, but you have to enter the commands by hand. If you use Windows, and edit over SSL, don't use Wordpad as

your editor. Use Notepad, or Crimson Editor...

Code: [Select]

service spamd stop

# writes the bayes_journal file to the database

sa-learn --sync

# moves files

cd /etc/mail/spamassassin
mv bayes.mutex /var/spool/spamd/.spamassassin
mv bayes_seen /var/spool/spamd/.spamassassin
mv bayes_toks /var/spool/spamd/.spamassassin


# removes temp learning directories. These
# are automatically added back by the d_gerst
# script if you still use it.

rmdir spam
rmdir missedspam
rmdir ham


# change owner/group back to defaults

chown root.root /etc/mail/spamassassin
chown root.root /etc/mail/spamassassin/bayes_filter.sh

# If you want to delete the d_gerst scripts and put
# your server back to the way it was:

rm /etc/mail/spamassassin/bayes_filter.sh
rm /etc/cron.d/sa-bayes_learning

# restore templates
# These templates are used to build the spamassassin
# config file local.cf. If you dont use bayes filtering
# then they arent used.

cd /etc/e-smith/templates/etc/mail/spamassassin/local.cf

# restore 10paths
# Edit the file 10paths, and replace the existing text.
# These arent commands! Paste this text in:

bayes_path /var/spool/spamd/.spamassassin/bayes
bayes_file_mode 750
auto_whitelist_path /var/spool/spamd/.spamassassin/auto-whitelist
auto_whitelist_file_mode 750


# 10internal_networks
# The file 10internal_networks was deleted by the script
# install_sa-learn.sh
# If you want to continue using the d_gerst scripts, leave
# it deleted.
# To restore it, create a file named 10internal_networks and
# paste this in:

{ "internal_networks $LocalIP" }



# del 71BayesFilter
# install_sa-learn.sh added the file 71BayesFilter.
# It sets the bayes_path incorrectly. Delete it:

rm /etc/e-smith/templates/etc/mail/spamassassin/local.cf/71BayesFilter

expand-template /etc/mail/spamassassin/local.cf

# Your /etc/mail/spamassassin/local.cf file should now look similar to this:

#------------------------------------------------------------
#       !!DO NOT MODIFY THIS FILE!!
#
# Manual changes will be lost when this file is regenerated.
#
# Please read the developer's guide, which is available
# at http://wiki.contribs.org/development/
#
# Copyright (C) 1999-2006 Mitel Networks Corporation
#------------------------------------------------------------
dns_available yes
lock_method flock
ok_languages all
ok_locales all
bayes_path /var/spool/spamd/.spamassassin/bayes
bayes_file_mode 750
auto_whitelist_path /var/spool/spamd/.spamassassin/auto-whitelist
auto_whitelist_file_mode 750
report_safe 0
required_hits 6
rewrite_header Subject [SPAM]
skip_rbl_checks 0
clear_trusted_networks
trusted_networks 192.168.1.5 127.
use_auto_whitelist 0
use_bayes 1


# Start it all back up

signal-event email-update
svc -t /service/qpsmtpd
service spamd start

# check the tokens are still there

sa-learn --dump magic

# shows something like this:

0.000          0          3          0  non-token data: bayes db version
0.000          0       3625          0  non-token data: nspam
0.000          0        286          0  non-token data: nham
0.000          0     126486          0  non-token data: ntokens
0.000          0 1161470280          0  non-token data: oldest atime
0.000          0 1163950938          0  non-token data: newest atime
0.000          0 1163921405          0  non-token data: last journal sync atime
0.000          0 1163292565          0  non-token data: last expiry atime
0.000          0          0          0  non-token data: last expire atime delta
0.000          0          0          0  non-token data: last expire reduction count