:: SPAMASSASSIN


Nome del pacchetto:   SpamAssassin
Sito di riferimento:   http://spamassassin.apache.org/
Autore:   ====
Versione presentata:   2.64
Categoria port:   MAIL

:: Descrizione del pacchetto

SpamAssassin è un filtro antispam (*) impiegato normalmente nei sistemi di posta elettronica per l'identificazione ed eliminazione di email non desiderate.
Questo pacchetto utilizza diversi tipi di filtro basati:

  • sull'analisi dell'header del messaggio;
  • sull'analisi del testo del messaggio;
  • sulle blacklist;
  • sulla classificazione delle probabilità attraverso sistemi bayesiani.
(*) Lo spam può essere definito come "posta elettronica non richiesta e indesiderata". Un esempio sono i numerosi messaggi pubblicitari che ogni giorno troviamo nella mailbox.

:: Installazione

SpamAssassin è disponibile tra i ports di FreeBSD. Per installarlo basta eseguire i seguenti comandi:

# cd /usr/ports/mail/p5-Mail-SpamAssassin
# make
# make install
# make clean

L'installazione è completata. Per verificare l'elenco dei file compresi nel pacchetto vi ricordiamo l'utilizzo di:

# pkg_info (elenco dei pacchetti tra cui p5-Mail-SpamAssassin)
# pkg_info -L [nome del pacchetto]

:: Configurazione

Come prima cosa verifichiamo il funzionamento di spamassassin utilizzando un messaggio di prova distribuito insieme al pacchetto.
Eseguiamo i seguenti comandi:

# cd /usr/local/share/doc/p5-Mail-Spamassassin
# spamassassin -t < sample-spam.txt > sample-spam.out

Riportiamo qui di seguito i due messaggi:

*************************************************************************
******** sample-spam.txt *********
Subject: Test spam mail (GTUBE)
Message-ID: < GTUBE1.1010101@example.net >
Date: Wed, 23 Jul 2003 23:30:00 +0200
From: Sender < sender@example.net >
To: Recipient < recipient@example.net>
Precedence: junk
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

This is the GTUBE, the
Generic
Test for
Unsolicited
Bulk
Email

If your spam filter supports it, the GTUBE provides a test by which you
can verify that the filter is installed correctly and is detecting incoming
spam. You can send yourself a test mail containing the following string of
characters (in upper case and with no white spaces and line breaks):

XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

You should send this test mail from an account outside of your network.


******** sample-spam.out *********

Received: from localhost by bsd.home.it with SpamAssassin (2.64 2004-01-11);
Mon, 09 Aug 2004 00:35:54 +0200
From: Sender < sender@example.net >
To: Recipient < recipient@example.net >
Subject: Test spam mail (GTUBE)
Date: Wed, 23 Jul 2003 23:30:00 +0200
Message-Id: < GTUBE1.1010101@example.net >
X-Spam-Level: **************************************************
X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) on bsd.home.it
X-Spam-Flag: YES
X-Spam-Status: Yes, hits=1001.4 required=5.0 tests=DNS_FROM_RFCI_DSN,GTUBE autolearn=no version=2.64
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_4116AACA.726DF2C2"

This is a multi-part message in MIME format.

------------=_4116AACA.726DF2C2
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
Spam detection software, running on the system "bsd.home.it", has
identified this incoming email as possible spam. The original message
has been attached to this so you can view it (if it isn't spam) or block
similar future email. If you have any questions, see
the administrator of that system for details.

Content preview: This is the GTUBE, the Generic Test for Unsolicited
Bulk Email If your spam filter supports it, the GTUBE provides a test
by which you can verify that the filter is installed correctly and is
detecting incoming spam. You can send yourself a test mail containing
the following string of characters (in upper case and with no white
spaces and line breaks): [...]

Content analysis details: (1001.4 points, 5.0 required)

pts rule name description
---- ---------------------- -------------------------------------------------- 1000 GTUBE BODY: Generic Test for Unsolicited Bulk Email
1.4 DNS_FROM_RFCI_DSN RBL: From: sender listed in dsn.rfc-ignorant.org

------------=_4116AACA.726DF2C2
Content-Type: message/rfc822; x-spam-type=original
Content-Description: original message before SpamAssassin
Content-Disposition: inline
Content-Transfer-Encoding: 8bit

Subject: Test spam mail (GTUBE)
Message-ID: < GTUBE1.1010101@example.net >
Date: Wed, 23 Jul 2003 23:30:00 +0200
From: Sender < sender@example.net >
To: Recipient < recipient@example.net >
Precedence: junk
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

This is the GTUBE, the
Generic
Test for
Unsolicited
Bulk
Email

If your spam filter supports it, the GTUBE provides a test by which you
can verify that the filter is installed correctly and is detecting incoming
spam. You can send yourself a test mail containing the following string of
characters (in upper case and with no white spaces and line breaks):

XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

You should send this test mail from an account outside of your network.
*************************************************************************

Come potete notare spamassassin funziona. Proseguiamo la configurazione editando il file /usr/local/etc/rc.d/spam.sh, file disponibile in seguito alla installazione del port, e apportiamo la seguente modifica (riportata in grassetto):

#!/bin/sh
#
# $FreeBSD: ports/mail/p5-Mail-SpamAssassin/files/spamd.sh,v 1.7 2004/03/30 20:21:04 sf Exp $
#
# PROVIDE: spamd
# REQUIRE: LOGIN
# BEFORE: mail
# KEYWORD: FreeBSD shutdown
#
# Add the following lines to /etc/rc.conf to enable spamd:
#
spamd_enable="YES"
#
# See spamd(8) for flags
#
. /usr/local/etc/rc.subr
name=spamd
rcvar=`set_rcvar`
command=/usr/local/bin/spamd
required_dirs=/usr/local/share/spamassassin
stop_postcmd=stop_postcmd
stop_postcmd()
{
    rm -f $pidfile
}
spamd_enable=${spamd_enable:-"NO"}
spamd_pidfile=${spamd_pidfile:-"/var/run/spamd.pid"}
spamd_flags=${spamd_flags:-"-a -c -d -r ${spamd_pidfile}"}
load_rc_config $name
run_rc_command "$1"

SpamAssassin utilizza inoltre un file di configurazione presente in /usr/local/etc/mail/spamassassin con il nome local.cf. Eseguiamo i seguenti comandi:

# cd /usr/local/etc/mail/spamassassin
# cp local.cf.sample local.cf
# vi local.cf
[CONTENUTO DEL FILE CON LE MODIFICHE APPORTATE]
rewrite subject 1
subject_tag [SPAM]

Un elenco completo delle opzioni di spamd è consultabile con il comando man spamd.

[ Pagina principale ]