Existen varias herramientas para hacerlo, como spamassasin o bogofilter. Dichas herrmamientas comprueban lo q llega al servidor de correo entrenate en mi caso es postfix, y borran los correos basura que llega.
Para eliminar el correo de un servidor pop o imap externo, deberemos usar otras herramientas, como animail.
apt-get install spamassassin bogofilter animail
Siendo:
cat /etc/spamassassin/local.cf ----------------------------------------------------------- rewrite_subject 1 full PARA_A_2_C_OF_1618 /Paragraph .a.{0,10}2.{0,10}C. of S. 1618/i describe PARA_A_2_C_OF_1618 Claims compliance with senate bill 1618 header FROM_HAS_MIXED_NUMS From =~ /\d+[a-z]+\d+\S*@/i describe FROM_HAS_MIXED_NUMS From: contains numbers mixed in with letters score A_HREF_TO_REMOVE 2.0 lang es describe FROM_FORGED_HOTMAIL Forzado From: simula ser de hotmail.com whitelist_from noticias@hispasec.com # http://bulmalug.net/body.phtml?nIdNoticia=1879. Eliminar gusano SWEN body SWEN /latest version of security.{1,10}update.{1,200}explorer.{1,50}outlook/i describe SWEN 'Swen worm' score SWEN 7.0 # Eliminar gusano IFRAME rawbody IFRAME /iframe src=\"cid/i describe IFRAME iframe score IFRAME 3.5 -----------------------------------------------------------
nano /etc/default/spamassassin ----------------------------------------------------------- ENABLED=1 OPTIONS="-c" -----------------------------------------------------------
Debemos tener en la configuración del servidor de correo postfix esto:
----------------------------------------------------------- cat /etc/postfix/main.cf ... mailbox_command = procmail -a "$EXTENSION" ... -----------------------------------------------------------
Configuraremos procmail de forma general asi, ya que uso el servidor de correo entrante courier-imap:
Y después hacer:
sa-learn --spam /a la/carpeta/de los/spams no detectados/
----------------------------------------------------------- DEFAULT=$HOME/Maildir/ :0fw | /usr/bin/spamc -f :0: * ^X-Spam-Status: Yes $HOME/Maildir/.spam/new #| echo "Paco, has recibido un correo basura de spamasasin" \ | festival --tts --language spanish :0 c | echo "Paco, has recibido un correo" \ | festival --tts --language spanish # | echo "Paco, has recibido un correo" \ | smbclient -M EQUIPO_WINDOWS -U alberto > /dev/null 2>&1 :0HB * ? bogofilter -u $HOME/Maildir/.spam/new :0 * ^List-Id:.*<sptex.ls.cica.es> $HOME/Maildir/.Sptex/new :0 * ^List-Id:.*<sl-educacion.listas.hispalinux.es> $HOME/Maildir/.Sl-educacion/new :0 * ^To:.*root@aldarias.dyndns.org $HOME/Maildir/.root/new :0 * ^To:.*paco@aldarias.dyndns.org $HOME/Maildir/.paco/new :0 * ^From:.*intercentres@centres.cult.gva.es /home/paco/Maildir/.intercentres/new :0 * ^From:.*apicv-digest-ayuda@eListas.net /home/paco/Maildir/.apicv/new :0 * ^From:.*stepv-intersindical@mail.intersindical.org /home/paco/Maildir/.stepv/new :0 * ^From:.*epublica-ensenyament@pv.ccoo.es /home/paco/Maildir/.CCOO-PV/new :0 * ^From:.*scomunic@pv.ugt.org /home/paco/Maildir/.FETE-UGT_PV/new -----------------------------------------------------------
Nota: Si no se desea un correo se puede enviar a /dev/hull
cat $HOME/maildir.sh ----------------------------------------------------------- # Ej. ./maildir.sh intercentres intercentres@centres.cult.gva.es echo creando carpeta $HOME/Maildir/$1 echo Lo que venga de $2 se metera en $HOME/Maildir/$1 mkdir $HOME/Maildir/.$1 mkdir $HOME/Maildir/.$1/new mkdir $HOME/Maildir/.$1/tmp mkdir $HOME/Maildir/.$1/cur echo " " >> $HOME/.procmailrc echo ":0" >> $HOME/.procmailrc echo "* ^From:.*$2" >> $HOME/.procmailrc echo "$HOME/Maildir/.$1/new" >> $HOME/.procmailrc -----------------------------------------------------------
cat .spamassassin/user_prefs
cat /etc/bogofilter.cf
nano $HOME/.animail/animailrc ----------------------------------------------------------- <Server> Alias: IMAP Server Address: imap.inicia.es Protocol: IMAP4 UserName: miusuario Passwd: mipass KeepOnServer: yes ResendTo: paco </Server> <Server> Alias: Pop Address: pop.loquesea.es Protocol: POP3 SSL: no Port: 110 UserName: miusuario Passwd: mipass KeepOnServer: yes ResendTo: paco </Server> # --------------------- Filtros <Global> FicheroFiltros: /home/paco/.animail/filtro # Para usar deliver debemos quitar resendto # Deliver_maildir: /home/paco/Maildir DownloadOrder: firstsmall </Global> <PostFilter> PostFilterName: SpamAssassin Path: /usr/bin/spamassassin KillerProgramOutput: ^X-Spam-Flag: YES.*$ SavePostFilteredMails: output </PostFilter> -----------------------------------------------------------
Le damos estos permisos:
chmod 600 $HOME/.animail/animailrc
Definicimos el fichero de filtros:
cat /home/paco/.animail/filtro ----------------------------------------------------------- ColderReinard@activatormail.com ithomas7f7n04klhtgjg@msn.com mrsmariamsese17@netscape.net returns-lokdzhkdwwyfgwt@optinbargains4u.com itziar@optenet.com -----------------------------------------------------------
Abrimos klipper - configurar - operaciones: Añadirmos uno nuevo q sea así:
Expresión regular: .^*@.* Operación: /hdd/personal/log/mailspam "%s"
cat /hdd/personal/log/mailspam ----------------------------------------------------------- #!/bin/sh echo "blacklist_from" $1 >> /home/paco/.spamassassin/user_prefs echo $1 >> $HOME/.animail/filtro -----------------------------------------------------------
cat /home/paco/.spamassassin/user_prefs ----------------------------------------------------------- #How many hits before a mail is considered spam? required_hits 6 #Don't mangle the messages so badly rewrite_subject 0 use_terse_report 1 #whitelist and blacklist whitelist_from *@spam-site-i-like.com blacklist_from annoying-person@some-host.com blacklist_from returns-pexgpnxgzzmiogg@rapiddealsbyemail.com blacklist_from palomero@fer.es blacklist_from *@commercecheck.com.com #reweight an existing rule score BASE64_ENC_TEXT 3 #add some new rules header KNOWN_LIST List-Id =~ /a-mailing-list-i-like/ score KNOWN_LIST -3 body EVITE /This invitation was sent to you by .* using Evite/ describe EVITE Looks like an eVite score EVITE -3 blacklist_from ColderReinard@activatormail.com blacklist_from ithomas7f7n04klhtgjg@msn.com blacklist_from mrsmariamsese17@netscape.net blacklist_from returns-lokdzhkdwwyfgwt@optinbargains4u.com blacklist_from itziar@optenet.com blacklist_from bss@fre.sg.co.nz blacklist_from by06r46s@commercecheck.com blacklist_from izlxk125lbz@commercecheck.com -----------------------------------------------------------
cat $HOME/.animail/filtro ----------------------------------------------------------- ColderReinard@activatormail.com ithomas7f7n04klhtgjg@msn.com mrsmariamsese17@netscape.net returns-lokdzhkdwwyfgwt@optinbargains4u.com -----------------------------------------------------------
Nota: podemos llamar a animail para q sólo borre los spams
así:
animail -F
Es posible instegrar kmail con spamassasin, aqui se explica
como se harian los filtros:
http://es.kde.org/modules/sections/index.php?op=viewarticle&artid=13
This document was generated using the LaTeX2HTML translator Version 2002-2-1 (1.70)
Copyright © 1993, 1994, 1995, 1996, Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999, Ross Moore, Mathematics
Department, Macquarie University, Sydney.
The command line arguments were:
latex2html spam -no_subdir -split 0
-local_icons 1 -show_section_numbers -no_auto_link
-no_navigation
The translation was initiated by Paco Aldarias on 2004-02-15