Author Topic: Integrate Bayesian classifier for Spam Filtering along with SpamAssassin  (Read 3199 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
In order for SpamAssassin to be accurate, you must train it on your specific mail patterns. SpamAssassin has a Bayesian classifier that can be used to help refine the classification of spam mail. The sa-learn interface allows you to train SpamAssassin to recognize good mail and junk mail. You need to train with both spam and ham mails. One type of mail alone will not have any effect.

To filter for spam:
  • Save spam into a new mail folder called Spam
  • Save non-spam (ham) into a new folder called Ham. You may also put messages that were marked as spam by mistake into this folder.
If you're having trouble with Bayes, see BayesFaq for help.
https://cwiki.apache.org/confluence/display/SPAMASSASSIN/BayesFaq

Spamassassin Default configuration:
Code: [Select]
# vi /etc/mail/spamassassin/local.cf
required_hits 5
report_safe 0
#required_score 5
rewrite_header Subject [SPAM]

Explanation:
Required_hits 5 is for small mail serv. You can increase it more if you need
Report_safe is on 0 here, but you can change to 1 or 2 ( see spamassassin guides )
Rewrite_header we call it ***SPAM*** here, you can call it as you want
Required_score can set form 0 -> 5 depends what you need

Configure the Bayesian classifier in Spamassassin:
Code: [Select]
# vi /etc/mail/spamassassin/local.cf
 use_bayes 1
 use_bayes_rules 1
 bayes_auto_learn 1
 bayes_path /etc/mail/spamassassin/bayes/
 bayes_file_mode 0660

 bayes_ignore_header X-Bogosity
 bayes_ignore_header X-Spam-Flag
 bayes_ignore_header X-Spam-Status
 include /usr/share/spamassassin/


Restart & Update Spamassassin rules
Code: [Select]
# systemctl restart spamassassin
# sa-update
Check Spamassassin status
Code: [Select]
# systemctl status spamassassin


If you get the above error that marked in snapshot , just disable the line (bayes_path) in /etc/mail/spamassassin/local.cf , It will use the default bayes_path .
Code: [Select]
#bayes_path /etc/mail/spamassassin/bayes/Just create new bayes databases
Code: [Select]
# sa-learn --sync
# sa-learn -p /etc/mail/spamassassin/local.conf --sync

Copy the existing bayes databases to Spamassassin Bayes directory:
Code: [Select]
# cp /root/.spamassassin/bayes_* /etc/mail/spamassassin/bayes/
Details with Troubleshooting :
How to Integrate Bayesian classifier in Spamassassin on CentOS Web Panel?