Como instruir a SpamAssasin en Alojamientos basados en cPanel
escrito por Juan Sierra Pons   
miércoles, 26 de noviembre de 2008
Compartelo:
Delicious
Meneame
Mister.Wong

Leyendo los foros de mi proveedor de alojamiento www.bluehost.com encontre un hilo muy interesante sobre como instruir SpamAssassin y despues de darle unas cuantas vueltas hice este scriprt para añadir la funcionalidad de que SpamAssasin se realimente de lo que los usuarios han marcado previamente como SPAM o NO SPAM.

Esto significa que con un solo script se añade la funcionalidad de "Marcar como Spam"  o bien "No es Spam"  que tienen algunos de los mas famososo webmail gratuitos Gmail, Yahoo, etc . Y por supuesto que SpamAssasin aprenda de ello  para todas las cuentas de todos los dominios que tengamos alojados. Eso si, siempre que la empresa de alojamiento este basada en cPanel.

 


 

El script lo hice en la lengua de Benny Hill pero es auto explicativo

 

Script InstruirSpamAssassin.sh
  1. #!/bin/sh
  2. # InstruirSpamAssassin.sh
  3. # TEACH YOUR SPAMASSASSIN script for cpanel (www.bluehost.com in this case) hosting accounts
  4. # This script teach your SPAMASSASIN daemon with HAM and SPAMUNCAUGTH from all the emails accounts of all your domains
  5.  
  6. #"THE BEER-WARE LICENSE" (Revision 42):
  7. #Juan Sierra Pons wrote this file. As long as you retain this notice you
  8. #can do whatever you want with this stuff. If we meet some day, and you
  9. #think this stuff is worth it, you can buy me a beer in return.
  10. #Juan Sierra Pons - juan [at} elsotanillo {dot] net
  11. #http://www.elsotanillo.net/
  12. #Original beerware license is due to Poul-Henning Kamp.
  13.  
  14. #SPAMASSASSIN CONFIGURATION
  15. #1.- Turn On Spamassasin: cPanel->Email Manager->Spam Assassin-> "Enable Spam Assassin"
  16. #2.- Turn on Bayes (auto learning for SA) "Configure Spam Assassin" -> check the box for "use-bayes".
  17.  
  18. #HOW TO SET UP USERS' EMAIL ACCOUNT
  19. #### always use the same name for HAM and UnCaughtSpam for all yours users
  20. # 1.- Create one folder for SPAMHAM
  21. # 2.- Create one folder for SPAMUNCAUGTH
  22. #USERS' INSTRUCTIONS
  23. # 1.- Move all your UnCaughtSpam messages to your UnCaughtSpam folder
  24. # 2.- Move all your HAM messages to your HAM folder
  25.  
  26. #HOW TO USE THIS SCRIPT:
  27. # 1.- Fill the LOGIN variable
  28. # 2.- Fill the SPAMHAMDIRECTORY variable
  29. # 3.- Fill the SPAMUNCAUGTH variable
  30. # 4.- Run this script using the crontab daemon once a day for example
  31. # 5.- After you check all is running ok for you, you can comment LOGSALEARN and LOGDEBUG lines
  32.  
  33. ########################## Variables ###########################
  34. LOGIN="logincpanel"
  35. SPAMHAMDIRECTORY="SpamHam"
  36. SPAMUNCAUGTH="SpamNoCogido"
  37. ### uncoment next line if you want to run sa-learn in verbose mode
  38. #LOGSALEARN="-D"
  39. ### LOGDEBUG=0 if you wan to see which accounts are being checked - only for debugging pourposes
  40. LOGDEBUG=0
  41. ### MOVESPAMHAMMESSAGES=0 if you want to move SPAMHAM messages to each INBOX directory after teach your spamassasin
  42. MOVESPAMHAMMESSAGES=1
  43. ### CLEANSPAMUNCAUGTHMESSAGES=0 if you want clean SPAMUNCAUGTH directory after teach your spamassassin
  44. CLEANSPAMUNCAUGTHMESSAGES=1
  45. ################################################## ##############
  46. for i in /home/$LOGIN/mail/*/*
  47. do
  48. ##### Teach SpamAssassin with HAM messages from SPAMHAM directory
  49. if [ $LOGDEBUG = 0 ] ;then echo ===== Checking $i/.$SPAMHAMDIRECTORY ========================== ; fi
  50. if test -d $i/.$SPAMHAMDIRECTORY/new; then nice -n 19 sa-learn $LOGSALEARN --ham --dir $i/.$SPAMHAMDIRECTORY/new; fi
  51. if test -d $i/.$SPAMHAMDIRECTORY/cur; then nice -n 19 sa-learn $LOGSALEARN --ham --dir $i/.$SPAMHAMDIRECTORY/cur; fi
  52. ##### move SPAMHAM messages to each INBOX directory
  53. if [ $MOVESPAMHAMMESSAGES = 0 ]
  54. then mv $i/.$SPAMHAMDIRECTORY/new/* $i/new ;mv $i/.$SPAMHAMDIRECTORY/cur/* $i/cur
  55. fi
  56. ##### Teach SpamAssassin from SPAMUNCAUGTH directory
  57. if [ $LOGDEBUG = 0 ] ;then echo ===== Checking $i/.$SPAMUNCAUGTH ========================== ; fi
  58. if test -d $i/.$SPAMUNCAUGTH/new; then nice -n 19 sa-learn $LOGSALEARN --spam --dir $i/.$SPAMUNCAUGTH/new; fi
  59. if test -d $i/.$SPAMUNCAUGTH/cur; then nice -n 19 sa-learn $LOGSALEARN --spam --dir $i/.$SPAMUNCAUGTH/cur; fi
  60. ##### Clean SPAMUNCAUGTH directory
  61. if [ $CLEANSPAMUNCAUGTHMESSAGES = 0 ]
  62. then rm $i/.$SPAMUNCAUGTH/new/*;rm $i/.$SPAMUNCAUGTH/cur/*
  63. fi
  64. done
 

 Si el LOGDEBUG esta activado, el script devolveria algo asi:

===== Checking /home/bluehostlogin/mail/elsotanillo.net/user1/.SpamHam ==========================
===== Checking /home/bluehostlogin/mail/elsotanillo.net/user1/.SpamNoCogido ==========================
===== Checking /home/bluehostlogin/mail/elsotanillo.net/user2/.SpamHam ==========================
Learned tokens from 0 message(s) (0 message(s) examined)
Learned tokens from 0 message(s) (0 message(s) examined)
===== Checking /home/bluehostlogin/mail/elsotanillo.net/user2/.SpamNoCogido ==========================
Learned tokens from 0 message(s) (0 message(s) examined)
Learned tokens from 3 message(s) (3 message(s) examined)
===== Checking /home/bluehostlogin/mail/elsotanillo.net/user3/.SpamHam ==========================
===== Checking /home/bluehostlogin/mail/elsotanillo.net/user3/.SpamNoCogido ==========================
===== Checking /home/bluehostlogin/mail/elsotanillo.net/user4/.SpamHam ==========================
===== Checking /home/bluehostlogin/mail/elsotanillo.net/user4/.SpamNoCogido ==========================
===== Checking /home/bluehostlogin/mail/the10thfloor.net/user1/.SpamHam ==========================
===== Checking /home/bluehostlogin/mail/the10thfloor.net/user1/.SpamNoCogido ==========================

Comentarios
Añadir nuevoBuscarRSS
replicawatche - thank you for the good post     | 187.4.128.xxx | 2010-04-16 05:56:12
It's so easy to choose high quality replica watches online: Rolex replica, Breitling replica, Chanel replica or any other watch from the widest variety of models and brands.
Escribir comentario
Nombre:
Email:
 
Website:
Título:
Código UBB:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
 
Security Image
Por favor introduce el código anti-spam que puedes leer en la imagen.

Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved.

Modificado el ( jueves, 04 de diciembre de 2008 )