Eliminar el spam con procmail

Por Paco Aldarias Raya

Impreso: 22 de agosto 2005

Email: pacolinux arroba inicia punto es

Web: http://aldarias.es/pacodebian

Con Linux Debian. En Valencia (España)

El documento tiene version .html, y .pdf, cambiando en el navegador la parte final podrás acceder a ambos.

Este documento es de libre reproducción siempre que se cite su fuente.

Realizado con: LATEX

Índice General

1 Versiones

2 Introducción

Vamos a ver la forma de coger el correo con postfix y filtrarlo con procmail, llegando a filtrar los spams.

3 Configurar postfix

En el fichero /etc/postfix/main.cf debera aparecer:

mailbox_command = procmail -a "$EXTENSION"

4 Fichero de configuracion

Editar el fichero: /home/paco/.procmailrc

LOGFILE=/var/log/procmail.log
DEFAULT=$HOME/Maildir/


#Spam
#http://www.uwasa.fi/~ts/info/proctips.html#flist
#I have a long list of spammers and other Internet lowlife in a separate file. How can I utilize it?

#The technique is fairly simple. Put this in your "~/.procmailrc" file:
#MAILDIR=/home/paco/Maildir   #The location of your own mail directory
# Whatever other preliminaries

# Whatever other recipes

# Test if the email's sender is in the blacklisted
:0
* ? formail -x"From" -x"From:" -x"Sender:" \
    -x"Reply-To:" -x"Return-Path:" -x"To:" \
    | egrep -is -f /home/paco/black.lst
/dev/null


:0 c
| lee  'Paco, has recibido un correo'

:0
* ^Subject:.*DOGV:
$HOME/Maildir/.diarios/new

:0
* ^Subject:.*BOE:
$HOME/Maildir/.diarios/new

:0
* ^Subject:.*Re:
/dev/null

:0
* ^List-Id:.*<sptex.ls.cica.es>
$HOME/Maildir/.Sptex/new

:0
* ^Sender:.*<ES-TEX@LISTSERV.REDIRIS.ES>
$HOME/Maildir/.Sptex/new


:0
* ^List-id:.*<lliurex_general.llistes.cult.gva.es>
$HOME/Maildir/.lliurex/new


:0
* ^List-id:.*<lliurex_modeloaula.llistes.cult.gva.es>
$HOME/Maildir/.lliurex/new


:0
* ^List-id:.*<lliurex_anuncios.llistes.cult.gva.es>
$HOME/Maildir/.lliurex/new

:0
* ^Sender:adoslista-bounces@aldarias.dyndns.org
/home/paco/Maildir/.ados/new

:0
* ^List-Id:.*<lliurex_anuncios.llistes.cult.gva.es>
$HOME/Maildir/.lliurex/new

:0
* ^List-Id:.*<lliurex_modeloaula.llistes.cult.gva.es>
$HOME/Maildir/.lliurex/new


:0
* ^List-Id:.*<erm-nav.bulma.net>
$HOME/Maildir/.erm-nav/new


:0
* ^List-Id:.*<sl-educacion.listas.hispalinux.es>
$HOME/Maildir/.Sl-educacion/new


:0
* ^List-Id:.*<debian-user-spanish.lists.debian.org>
$HOME/Maildir/.debian-user-spanish/new


:0
* ^List-Id:.*<ltsp-es.listas.hispalinux.es>
$HOME/Maildir/.ltsp-es/new


:0
* ^To:.*root@aldarias.dyndns.org
$HOME/Maildir/.root/new

:0
* ^To:.*paco@aldarias.dyndns.org
$HOME/Maildir/.paco/new


:0
* ^To:.*faldarias@centres.cult.gva.es
$HOME/Maildir/.ceed/new

:0
* ^To:.*faldarias@centres.cult.gva.es
! paco@ceedcv.com

:0
* ^To:.*ados@aldarias.dyndns.org
$HOME/Maildir/.ados/new


:0
* ^To:.*ceed@aldarias.dyndns.org
$HOME/Maildir/.ceed/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:.*gladysp73@hotmail.com
#/home/paco/Maildir/.gladys/new

:0
* ^To:.*pacocap@tiscali.es
/home/paco/Maildir/.cap/new

:0
* ^To:.*paldaria@hotmail.com
/home/paco/Maildir/.hotmail/new

:0
* ^To:.*paldaria@yahoo.com
/home/paco/Maildir/.yahoo/new


:0
* ^X-Apparently-To:
/home/paco/Maildir/.yahoo/new

:0
* ^From:.*gladysp73@yahoo.es
/home/paco/Maildir/.gladys/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


# Los spam se miran al final para q tarde menos.
# The following line is only used if you use a system-wide /etc/procmailrc.
# See procmailrc(5) for infos on what it exactly does, the short version:
#  * It ensures that the correct user is passed to spamd if spamc is used
#  * The folders the mail is filed to later on is owned by the user, not
#    root.
DROPPRIVS=yes

# Pipe the mail through spamassassin (replace 'spamassassin' with 'spamc'
# if you use the spamc/spamd combination)
#
# The condition line ensures that only messages smaller than 250 kB
# (250 * 1024 = 256000 bytes) are processed by SpamAssassin. Most spam
# isn't bigger than a few k and working with big messages can bring
# SpamAssassin to its knees.
#
# The lock file ensures that only 1 spamassassin invocation happens
# at 1 time, to keep the load down.
#
:0fw: spamassassin.lock
* < 256000
| spamassassin

# Mails with a score of 15 or higher are almost certainly spam (with 0.05%
# false positives according to rules/STATISTICS.txt). Let's put them in a
# different mbox. (This one is optional.)
:0:
* ^X-Spam-Level: \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
/dev/null

# All mail tagged as spam (eg. with a score higher than the set threshold)
# is moved to "probably-spam".
:0:
* ^X-Spam-Status: Yes
/dev/null

# Work around procmail bug: any output on stderr will cause the "F" in "From"
# to be dropped.  This will re-add it.
# NOTE: This is probably NOT needed in recent versions of procmail
:0
* ^^rom[ ]
{
  LOG="*** Dropped F off From_ header! Fixing up. "

  :0 fhw
  | sed -e '1s/^/F/'
}

:0fw
| /usr/bin/spamc -f
/home/user/bin/SpamAssassin/spamassassin -P -c /home/user/bin/SpamAssassin/rules


#:0:
#* ^X-Spam-Status: Yes
#/dev/null
#/home/paco/Maildir/.spam/new

:0
* ^Subject:.*VIRUS
/dev/null
#/home/paco/Maildir/.spam/new


#:0HB
#* ? bogofilter -u
#/dev/null

#:0fw
#| bogofilter -p -u -l -e -v

#/home/paco/Maildir/.spam/new
#$HOME/Maildir/.spam/new
#| echo "Paco, has recibido un correo spam con bogofilter" | festival --tts --language spanish


## Silently drop all Asian language mail
UNREADABLE='[^?"]*big5|iso-2022-jp|ISO-2022-KR|euc-kr|gb2312|ks_c_5601-1987'
:0:
        * 1^0 $ ^Subject:.*=\?($UNREADABLE)
        * 1^0 $ ^Content-Type:.*charset="?($UNREADABLE)
        spam-unreadable

:0:
   * ^Content-Type:.*multipart
   * B ?? $ ^Content-Type:.*^?.*charset="?($UNREADABLE)
   spam-unreadable

# Eliminar repetidos
:0 Wh: msgid.lock
        | formail -D 8192 msgid.cache

        ## To stop saving mail, pipe to /dev/null

:0 a: dups/$LOCKEXT
        | ${RCVSTORE} +dups

# Pyzor /usr/share/doc/pyzor/usage.html
#:0 Wc
#| pyzor check
#:0 Waf
#| formail -A 'X-Pyzor: spam'

5 Bibliografía

  1. PROCMAIL-SPAM:
    http://www.uwasa.fi/~ts/info/proctips.html#flist


Índice de Materias

Sobre este documento...

Eliminar el spam con procmail

This document was generated using the LaTeX2HTML translator Version 2002-2-1 (1.71)

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 procmail -split 0 -local_icons 1 -show_section_numbers -no_auto_link -no_navigation

The translation was initiated by on 2005-08-22


2005-08-22