返回列表 回复 发帖

My dspam Training Script

  1. #!/bin/sh

  2. # train-spam.sh
  3. #
  4. # Description: Checks each user's /home/Maildir/.Spam.Missed
  5. # directories to see if the user placed any "missed" spam
  6. # messages which got through SpamAssassin to their INBOX.
  7. # If there are messages in this directory, then the script
  8. # invokes sa-learn to update the site-wide tokens to try
  9. # and improve the defenses for next time...
  10. #

  11. # learn_spam - Function which takes a directory and a user as
  12. #  arguments, and then feeds that directory to our anti-spam
  13. #  applications for further SPAM training.
  14. #
  15. # Arguments:
  16. #  $1 - Directory name containing SPAM emails. Required
  17. #  $2 - User name. If it is not provided, $USER will be used.
  18. #
  19. # Example:
  20. #  learn_spam /home/alank/Maildir/.Spam.Missed/cur alank
  21. #
  22. function learn_spam {

  23.     # loop through all emails in given directory
  24.     for email in $(ls $1); do

  25.             # process SPAM email using DSPAM
  26.         /usr/local/bin/dspam --mode=teft --source=error --class=spam --feature=chained,noise --user $2 < $1/$email
  27.             echo -n "."

  28.             # delete SPAM email
  29.             rm $1/$email

  30.     done # end of email loop

  31. } # end function learn_spam

  32. # learn_ham - Function which takes a directory and a user as
  33. #  arguments, and then feeds that directory to our anti-spam
  34. #  applications for further HAM training.
  35. #
  36. # Arguments:
  37. #  $1 - Directory name containing HAM emails. Required
  38. #  $2 - User name. If it is not provided, $USER will be used.
  39. #
  40. # Example:
  41. #  learn_ham /home/alank/Maildir/.Spam.NotSpam/cur alank
  42. #
  43. function learn_ham {

  44.     # loop through all emails in given directory
  45.     for email in $(ls $1); do

  46.             # process HAM email using DSPAM
  47.         /usr/local/bin/dspam --mode=teft --source=error --class=innocent --feature=chained,noise --user $2 < $1/$email
  48.         echo -n "."

  49.             # delete HAM
  50.             rm $1/$email

  51.     done # end of email loop

  52. } # end function learn_ham

  53. #
  54. # Script starts here!
  55. #

  56. # loop through all user home directories
  57. for file in $(ls /home); do

  58.     # if there is a Spam/Missed maildir
  59.     if [ -d /home/$file/Maildir/.Spam.Missed/cur ]; then
  60.        
  61.             # then process any missed SPAM
  62.             echo -n "missed spam for $file: "
  63.             learn_spam /home/$file/Maildir/.Spam.Missed/cur $file
  64.             learn_spam /home/$file/Maildir/.Spam.Missed/new $file
  65.             echo ""
  66.        
  67.     fi # end if

  68.     # if there is a Spam/NotSpam dir
  69.     if [ -d /home/$file/Maildir/.Spam.NotSpam/cur ]; then
  70.        
  71.             # then process any falsely identified spam, i.e. HAM
  72.             echo -n "false positives for $file: "
  73.             learn_ham /home/$file/Maildir/.Spam.NotSpam/cur $file
  74.             learn_ham /home/$file/Maildir/.Spam.NotSpam/new $file
  75.             echo ""

  76.     fi # end if

  77. done # end for loop

  78. echo "Done!"
复制代码
附件: 您需要登录才可以下载或查看附件。没有帐号?注册
成都成都Linux维护,代维。FreeBSD维护,代维,维护各种服务器。
返回列表
开源邮件服务器 开源邮件服务器 web 开源邮件 开源 mail 开源 邮件服务器 邮件技术 mail技术 反垃圾邮件 反垃圾mail mail投递
邮件服务器 mail服务器 开源软件 mail软件 mail服务新品牌 开源邮件服务新品牌
开源mail服务新网站 邮件服务新品牌 mail tmail mailserver 163邮件 sendmail |Linux维护|Linux代维|成都Linux维护|成都Linux代维