The Perfect SpamSnake - Ubuntu Jeos 9.10 - Page 2

4. Caching Dnsmasq

apt-get install dnsmasq

Edit /etc/dnsmasq.conf and make Dnsmasq listen on localhost:

listen-address=127.0.0.1

Edit /etc/resolv.conf and append the following to the top of the list:

nameserver 127.0.0.1

 

5. Install Apache2 and Mysql

apt-get install apache2 php5-cli libapache2-mod-php5 mysql-client mysql-server libdbd-mysql-perl php5-gd php5-mysql

 

Install MySql

You will be asked to provide a password for the MySQL root user - this password is valid for the user root@localhost as well as root@server1.example.com, so we don't have to specify a MySQL root password manually later on:

New password for the MySQL "root" user: <-- yourrootsqlpassword
Repeat password for the MySQL "root" user: <-- yourrootsqlpassword

 

Install Apache2

apt-get install apache2 apache2-doc apache2-mpm-prefork apache2-utils apache2-suexec

Next we install PHP5 as an Apache module:

aptitude install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-mysql php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

Next we edit /etc/apache2/mods-available/dir.conf and change the DirectoryIndex line:

<IfModule mod_dir.c>
          #DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
          DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3 index.pl index.xhtml
</IfModule>

Now we have to enable some Apache modules (rewrite, suexec, include):

a2enmod rewrite
a2enmod suexec
a2enmod include

Restart Apache:

/etc/init.d/apache2 restart

 

Install Postfix:

Install the packages:

apt-get install postfix postfix-mysql postfix-doc procmail

 

Postfix:

You will be asked two questions. Answer as follows:

General type of mail configuration: --> Internet Site
System mail name: --> server1.example.com

Stop Postfix:

postfix stop

We’ll want to edit Postfix with the below:

Edit master.cf:
We need to add two items below the pickup service type. The pickup service "picks up" local mail (local meaning "on this machine") and delivers it. This is a way to bypass content filtering for mail generated by this machine.

It should look like this when you are done:

pickup    fifo  n       -       -       60      1       pickup
         -o content_filter=
         -o receive_override_options=no_header_body_checks

Note: For this step, make sure to replace anything@example.com, example.com and @example.com with real values that matches your setup.

Edit main.cf:

postconf -e "alias_maps = hash:/etc/aliases"
newaliases
postconf -e "myorigin = example.com"
postconf -e "myhostname = server1.example.com"
postconf -e "mynetworks = 127.0.0.0/8, 192.168.0.0/24”
postconf -e "message_size_limit = 10485760"
postconf -e "local_transport = error:No local mail delivery"
postconf -e "mydestination = "
postconf -e "local_recipient_maps = "
postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"

Create /etc/postfix/virtual and add the following:

postmaster postmaster@example.com
abuse abuse@example.com
root root@example.com

Continue:

postmap /etc/postfix/virtual
postconf -e "relay_recipient_maps = hash:/etc/postfix/relay_recipients"

Create /etc/postfix/relay_recipients and add the following:

@example.com OK
@example2.com OK

Continue:

postmap /etc/postfix/relay_recipients
postconf -e "transport_maps = hash:/etc/postfix/transport"

Create /etc/postfix/transport and add the following:

example.com smtp:[192.168.0.x]
example2.com smtp:[192.168.0.x]

Continue:

postmap /etc/postfix/transport
postconf -e "relay_domains = hash:/etc/postfix/relay_domains"

Create /etc/postfix/relay_domains and add the following:

example.com OK
example2.com OK

Continue:

postmap /etc/postfix/relay_domains
postconf -e "smtpd_helo_required = yes"
postconf -e "smtpd_sender_restrictions = reject_non_fqdn_sender, reject_unknown_sender_domain, permit"
postconf -e "smtpd_recipient_restrictions = reject_non_fqdn_recipient, permit_mynetworks, reject_unauth_destination, reject_unauth_pipelining, reject_rbl_client zen.spamhaus.org, reject_rbl_client bl.spamcop.net, permit"
postconf -e "smtpd_data_restrictions = reject_unauth_pipelining"

Final look at the Postfix install:

less /etc/postfix/main.cf

Check the contents of the file for errors and repair if needed. Fire up Postfix:

postfix start

Check that Postfix responds:

telnet 127.0.0.1 25

You should see:

220 [yourFQDNhere] ESMTP Postfix (Ubuntu)

 

6. Install Razor, Pyzor, DCC and Clamav

apt-get install razor pyzor clamav-daemon

 

DCC Configuration

Install DCC from .deb source:

cd /tmp
wget http://ppa.launchpad.net/jonasped/ppa/ubuntu/pool/main/d/dcc/dcc-common_1.3.113-0ubuntu1~ppa1~karmic1_i386.deb && dpkg -i dcc-common_1.3.113-0ubuntu1~ppa1~karmic1_i386.deb
wget http://ppa.launchpad.net/jonasped/ppa/ubuntu/pool/main/d/dcc/dcc-server_1.3.113-0ubuntu1~ppa1~karmic1_i386.deb && dpkg -i dcc-server_1.3.113-0ubuntu1~ppa1~karmic1_i386.deb
wget http://ppa.launchpad.net/jonasped/ppa/ubuntu/pool/main/d/dcc/dcc-client_1.3.113-0ubuntu1~ppa1~karmic1_i386.deb && dpkg -i dcc-client_1.3.113-0ubuntu1~ppa1~karmic1_i386.deb

Test our installation with:

cdcc info

You should get 'requests ok' from the servers. Install dependencies:

aptitude install libconvert-tnef-perl libdbd-sqlite3-perl libfilesys-df-perl libmailtools-perl libmime-tools-perl libmime-perl libnet-cidr-perl libsys-syslog-perl libio-stringy-perl libfile-temp-perl libole-storage-lite-perl libarchive-zip-perl libsys-hostname-long-perl libnet-cidr-lite-perl libhtml-parser-perl libdb-file-lock-perl libnet-dns-perl libncurses5-dev libdigest-hmac-perl libdigest-sha1-perl libnet-ip-perl liburi-perl libfile-spec-perl spamassassin libnet-ident-perl libmail-spf-query-perl libmail-dkim-perl dnsutils

Download and install the latest MailScanner:

wget http://www.mailscanner.info/files/4/tar/MailScanner-install-4.78.17-1.tar.gz
tar xvfz MailScanner-install-4.78.17-1.tar.gz && cd MailScanner-install-4.78.17
./install.sh

 

Configuring Pyzor, Razor, MailScanner

Pyzor Configuration

Because pyzor doesn’t work with python2.6 very well, the workaround is to append the following to the first line of /usr/bin/pyzor to make it look like:

#!/usr/bin/python -Wignore::DeprecationWarning

Here we supply the IP address of the Pyzor server to Pyzor. This will create the server's IP address in a servers file therein. Then it will test the connection. If you are behind a firewall, open port 24441/udp in and out to your server. While you're at it also open up 6277/udp for DCC, 2703/tcp for Razor and 783/tcp for SpamAssassin:

mkdir /var/lib/MailScanner
pyzor --homedir=/var/lib/MailScanner discover
pyzor ping

 

Razor Configuration

Create the .razor configuration:

cd && rm /etc/razor/razor-agent.conf
mkdir /var/lib/MailScanner/.razor
razor-admin -home=/var/lib/MailScanner/.razor -create
razor-admin -home=/var/lib/MailScanner/.razor -discover
razor-admin -home=/var/lib/MailScanner/.razor -register
chown -R postfix:www-data /var/lib/MailScanner
chmod -R ug+rwx /var/lib/MailScanner

Make the following changes to /var/lib/MailScanner/.razor/razor-agent.conf:

debuglevel        = 0
razorhome 	  = /var/lib/MailScanner/.razor/

 

MailScanner Configuration

We need to make a directory for SpamAssassin in the spool and give postfix permissions to it, if you run sa-learn --force as root, bayes databese that is stored in these directories will change to root:root and spamassassin will error looking at the db. Just keep an eye on the mail.log and you'll remember to change the permissions back. Also disable the MailScanner default configs:

mkdir /var/spool/MailScanner/spamassassin

Backup your MailScanner.conf file:

cp /opt/MailScanner/etc/MailScanner.conf /opt/MailScanner/etc/MailScanner.conf.dist
vi /opt/MailScanner/etc/MailScanner.conf

Change the following parameters in MailScanner.conf:

%org-name% = ORGNAME
%org-long-name% = ORGFULLNAME
%web-site% = ORGWEBSITE
Run As User = postfix
Run As Group = www-data
Incoming Work Group = clamav
Incoming Work Permissions = 0644
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = postfix
Virus Scanners = clamd
Monitors for ClamAV Updates = /var/lib/clamav/*.cld /var/lib/clamav/*.cvd
Clamd Socket = /var/run/clamav/clamd.ctl
Clamd Lock File = /var/run/clamav/clamd.pid
Spam Subject Text = ***SPAM***
Send Notices = no
Spam List = spamcop.net ZEN
Spam Actions = deliver store header “X-Spam-Status: Yes”
High Scoring Spam Actions = store delete
Non Spam Actions = deliver store header “X-Spam-Status: No”
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin

 

header_checks

Let's go ahead and put this in main.cf. header_checks is required because it allows us to hold all incoming email in order for MailScanner to do its thing:

postconf -e "header_checks = regexp:/etc/postfix/header_checks"

Create /etc/postfix/header_checks and add the following:

/^Received:/ HOLD

Postmap it:

postmap /etc/postfix/header_checks

 

MailScanner Startup Script:

Save the following as /etc/init.d/mailscanner:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          MailScanner daemon
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Controls mailscanner instances
# Description:       MailScanner is a queue-based spam/virus filter
### END INIT INFO
# Author: Simon Walter <simon.walter@hp-factory.de>
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/usr/sbin:/usr/bin:/bin:/sbin:/opt/MailScanner/bin
DESC="mail spam/virus scanner"
NAME=MailScanner
PNAME=mailscanner
DAEMON=/opt/MailScanner/bin/$NAME
STARTAS=MailScanner
SCRIPTNAME=/etc/init.d/$PNAME
CONFFILE=/opt/MailScanner/etc/MailScanner.conf
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
run_nice=0
stopped_lockfile=/var/lock/subsys/MailScanner.off
# Read configuration variable file if it is present
[ -r /etc/default/$PNAME ] && . /etc/default/$PNAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
# sanity check for permissions
fail()
{
    echo >&2 "$0: $1"
    exit 1
}
check_dir()
{
    if [ ! -d $1 ]; then
        mkdir -p "$1" || \
            fail "directory $1: does not exist and cannot be created"
    fi
    actual="$(stat -c %U $1)"
    if [ "$actual" != "$2" ]; then
        chown -R "$2" "$1" || \
            fail "directory $1: wrong owner (expected $2 but is $actual)"
    fi
    actual="$(stat -c %G $1)"
    if [ "$actual" != "$3" ]; then
        chgrp -R "$3" "$1" || \
            fail "directory $1: wrong group (expected $3 but is $actual)"
    fi
}
user=$(echo $(awk -F= '/^Run As User/ {print $2; exit}' $CONFFILE))
group=$(echo $(awk -F= '/^Run As Group/ {print $2; exit}' $CONFFILE))
check_dir /var/spool/MailScanner       ${user:-postfix} ${group:-www-data}
check_dir /var/lib/MailScanner         ${user:-postfix} ${group:-www-data}
check_dir /var/run/MailScanner         ${user:-postfix} ${group:-www-data}
check_dir /var/lock/subsys	${user:-root}	${group:-root} #Required to Create Folder
check_dir /var/lock/subsys/MailScanner ${user:-postfix} ${group:-www-data}
#
# Function that starts the daemon/service
#
do_start()
{
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started
        start-stop-daemon --start --quiet --startas $STARTAS --name $NAME --test > /dev/null \
                || return 1
        start-stop-daemon --start --quiet --nicelevel $run_nice --chuid postfix:www-data --exec $DAEMON --name $NAME -- $DAEMON_ARGS \
                || return 2
        # Add code here, if necessary, that waits for the process to be ready
        # to handle requests from services started subsequently which depend
        # on this one.  As a last resort, sleep for some time.
  # Set lockfile to inform cronjobs about the running daemon
        RETVAL="$?"
        if [ $RETVAL -eq 0 ]; then
            touch /var/lock/subsys/mailscanner
            rm -f $stopped_lockfile
        fi
if [ $RETVAL -eq 0 ]; then
echo "MailScanner Started"
fi
}
#
# Function that stops the daemon/service
#
do_stop()
{
        # Return
        #   0 if daemon has been stopped
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred
        start-stop-daemon --stop --retry=TERM/30 --name $NAME
        RETVAL="$?"
        [ "$RETVAL" = 2 ] && return 2
  # Remove lockfile for cronjobs
        if [ $RETVAL -eq 0 ]; then
            rm -f /var/lock/subsys/mailscanner
            touch $stopped_lockfile
        fi
if [ $RETVAL -eq 0 ]; then
echo "MailScanner Stopped"
fi
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
        start-stop-daemon --stop --signal 1 --quiet --name $NAME
        return 0
}
case "$1" in
  start)
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
        do_start
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  stop)
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
        do_stop
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  restart|force-reload)
        #
        # If the "reload" option is implemented then remove the
        # 'force-reload' alias
        #
        log_daemon_msg "Restarting $DESC" "$NAME"
        do_stop
        case "$?" in
          0|1)
                do_start
                case "$?" in
                        0) log_end_msg 0 ;;
                        1) log_end_msg 1 ;; # Old process is still running
                        *) log_end_msg 1 ;; # Failed to start
                esac
                ;;
          *)
                # Failed to stop
                log_end_msg 1
                ;;
        esac
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
        exit 3
        ;;
esac
exit 0

Create Symlinks for mailscanner script to work:

chmod 755 /etc/init.d/mailscanner
ln -s ../init.d/mailscanner /etc/rc0.d/K20mailscanner
ln -s ../init.d/mailscanner /etc/rc1.d/K20mailscanner
ln -s ../init.d/mailscanner /etc/rc2.d/S20mailscanner
ln -s ../init.d/mailscanner /etc/rc3.d/S20mailscanner
ln -s ../init.d/mailscanner /etc/rc4.d/S20mailscanner
ln -s ../init.d/mailscanner /etc/rc5.d/S20mailscanner
ln -s ../init.d/mailscanner /etc/rc6.d/K20mailscanner

Start the system:

/etc/init.d/mailscanner start
/etc/init.d/postfix start

Check your logs for errors:

tail -f /var/log/mail.log

Share this page:

54 Comment(s)

Add comment

Comments

From: 011 at: 2010-04-23 01:51:00

Does this apply to Debian too or there are specific steps for it?

From: at: 2010-04-26 17:38:36

Debian should also work, but I don't know for sure.  I chose Ubuntu because it's a bit more updated than Debian with certain packages.

From: bluegrass at: 2010-08-04 07:04:07

Hi,  will this apply on an existing Virtual Users and Domains with Postfix, Courier, MySQL?  Or it should be installed on a separate hardware?

From: at: 2010-08-17 02:41:15

This is a standalone install, but can possibly be converted to a virtual setup.  I personally haven't tried it though.

From: iser0073 at: 2010-07-26 12:40:04

Thanx for the coolest anti spam solutions I have found!! It is really appreciated.

In the line:

postconf -e "mynetworks = 127.0.0.0/8, 192.168.0.0/24”

 the ” at the end of this line translates to a . when copying and pasting from this guide, would be cool if you could simply replace it with a "

 Kind Regards,
Johan

From: devnull1369 at: 2010-08-20 20:54:06

DCC has moved.

 

http://ppa.launchpad.net/jonasped/ubuntu/pool/main/d/dcc/dcc-server_1.3.130-0ubuntu1~ppa1~karmic1_i386.deb

http://ppa.launchpad.net/jonasped/ubuntu/pool/main/d/dcc/dcc-common_1.3.130-0ubuntu1~ppa1~karmic1_i386.deb

http://ppa.launchpad.net/jonasped/ubuntu/pool/main/d/dcc/dcc-client_1.3.130-0ubuntu1~ppa1~karmic1_i386.deb

 

From: fredux at: 2010-04-24 14:49:34

Help me!!!

 Bayes error:

 [21180] dbg: bayes: using username: root
[21180] dbg: bayes: database connection established
[21180] dbg: bayes: found bayes db version 3
[21180] dbg: bayes: unable to initialize database for root user, aborting!

Why????

br,

 fredux

From: at: 2010-04-25 16:51:28

Has any spam email been processed yet? Maybe that is the reason.

From: fredux at: 2010-04-26 11:12:54

no, no message in queue. still in installation!!!

thanks

 Best regards,

Fred

From: Eddo Jansen at: 2010-07-02 06:54:36

First initialize the database by running the following command:

/usr/bin/sa-learn --force-expire --sync -p /opt/MailScanner/etc/spam.assassin.prefs.conf

From: 011 at: 2010-04-23 01:56:01

Mailwatch is at 1.0.5 right now. Is it OK to install that one?

Url for download of the patch is http://www.gbnetwork.co.uk/mailscanner/files/postfixmail.tar.gz

Did not have time to check if this is patch for 1.05 as well.

From: at: 2010-04-29 02:38:25

I think the only difference is compatibility with php5, otherwise, everything is the same. It should work.  This is what I found on their support site:

## 1.0.5 - VERY BASIC alterations so that MailWatch also runs on PHP5.3 and MySql5.1

From: Anonymous at: 2010-06-18 12:31:33

I think I buggered up the GeoIP line , I changed the whole line to look like :

 dbquery("LOAD DATA LOCAL INFILE

 What are the rest of the code behind it please :)

From: Joolee at: 2010-11-30 08:43:37

  dbquery("LOAD DATA LOCAL INFILE '".$base.'/'.$file2."' INTO TABLE geoip_country FIELDS TERMINATED BY ',' ENCLOSED BY '\"'");

 That's what it's supposed to look like after editing.

From: at: 2010-04-25 16:53:57

I believe the file to be edited for "Fix to allow wildcards in Whitelist/Blacklist" should be /opt/MailScanner/lib/MailScanner/CustomFunctions/SQLBlackWhiteList.pm

From: at: 2010-04-29 02:29:23

Correct, updated.

From: at: 2010-04-25 16:59:52

Directory /var/www/mailscanner/temp should also be apache writeable because MailWatch cannot extract the csv fle upon update.

Recommended fix:  replace procedure under title:

Install & Configure MailWatch - Make a temp directory:

mkdir temp
chmod g+w temp

chown root:www-data temp

From: at: 2010-04-29 02:27:45

Guide updated.

From: fredux at: 2010-04-26 20:52:52

Clamd Error Fix not work, I'm change user in clamd.conf to work using root and fix, do you have any other idea? sorry my english!

Best regards,

fredux

From: at: 2010-04-29 02:39:41
From: Anonymous at: 2010-07-23 13:49:16

This has solved for me.....

http://www.howtoforge.net/forums/showthread.php?t=45475

From: 011 at: 2010-05-10 16:44:15

I have a problem with "Fix to Allow Multiple Release of Messages in Message Operations" section.

Second step more specificaly.

Could you, please, point out what is the "following section" in "Then, find the following section and change it to look like this:" that needs ot be replaced with givcen code.

 

Thanks.

From: at: 2010-05-27 12:35:22

It's pretty clear, just find that section in the file, and change it to look like what's posted.

From: ihamouda at: 2010-07-03 18:19:11

This section doesn't exists in the file "do_message_ops.php" at least in version 1.0.5

Do you have any idea what file it was moved to?

From: at: 2010-07-13 17:55:42

Make a backup of your file and copy the content below and overwrite your original with it.  You should be good to go after that.

<?
/*
 MailWatch for MailScanner
 Copyright (C) 2003  Steve Freegard (smf@f2s.com)

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

require_once('./functions.php');
require_once('DB.php');
require_once('DB/Pager.php');
require_once('./filter.inc');
session_start();
authenticate();
$refresh = html_start("Operation Results");

echo "<TABLE BORDER=0 WIDTH=\"100%\" CLASS=\"maildetail\">\n";
echo " <THEAD>\n";
echo "  <TH>Spam Learn Results</TH>\n";
echo " </THEAD>\n";
echo "  <TR>\n";
echo "  <TD CLASS=\"detail\">";

// Iterate through the POST variables
//Edited 1/5/09 Original = $id = $Regs[1];
if(is_array($_POST)) {
 foreach($_POST as $k=>$v) {
  if (preg_match('/^OPT-(.+)$/', $k, $Regs)) {
   $id = str_replace("_", ".",$Regs[1]);
  } else {
   continue;
  }
  switch ($v) {
   case 'S':
    $type='spam';
    break;
   case 'H':
    $type='ham';
    break;
   case 'F':
    $type='forget';
    break;
   case 'R':
    $type='release';
    break;
   default:
    continue;
    break;
  }
  $items = quarantine_list_items($id,RPC_ONLY);
  echo "<TABLE WIDTH=100%>\n";
  if(count($items) > 0) {
   foreach($items as $num=>$item) {
    if ($item['file'] == 'message') {
$itemnum = array($num);
   if ($type == 'release'){
      if($quarantined = quarantine_list_items($id,RPC_ONLY)) {
         $to = $quarantined[0]['to'];
       }
       echo "<tr><td><a href=\"detail.php?id=$id\">$id</a></td><td>$type</td><td>" . quarantine_release($quarantined, $itemnum, $to, RPC_ONLY) . "</td></tr>\n";
    } else {
     echo "<tr><td><a href=\"detail.php?id=$id\">$id</a></td><td>$type</td><td>" . quarantine_learn($items, $itemnum, $type, RPC_ONLY) . "</td></tr>\n";
     }
   }
  echo "</TABLE>\n";
      }
    }
  }
}
echo "  </TD>\n";
echo " </TR>\n";
echo " </TABLE>\n";

echo "<p><a href=\"javascript:history.back(1)\">Back</a>";

html_end();
?>
 

From: Eddo Jansen at: 2010-07-07 06:05:15

Same here, that section does not exists, I have the following:

 case 'S':
    $type='spam';
    break;
   case 'H':
    $type='ham';
    break;
   case 'F':
    $type='forget';
    break;
   default:
    continue;
    break;
  }
  $items = quarantine_list_items($id,RPC_ONLY);
  echo "<TABLE WIDTH=100%>\n";
  if(count($items) > 0) {
   foreach($items as $num=>$item) {
    if ($item['file'] == 'message') {
     $itemnum = array($num);
      echo "<tr><td><a href=\"detail.php?id=$id\">$id</a></td><td>$type</td><td>" . quarantine_learn($items, $itemnum, $type, RPC_ONLY) . "</td></tr>\n";;
    }
   }
  } else {
   echo "<tr><td colspan=3>Message $id not found in quarantine</td></tr>\n";
  }
  echo "</TABLE>\n";

Any advise??

 

From: PieterJ at: 2010-05-17 20:42:53

I added dcc_path /usr/bin/dccproc to the top of /opt/MailScanner/etc/spam.assassin.prefs.conf

The lint test gave this error:

[13033] info: config: dcc_path "/usr/local/bin/dccproc" isn't an executable
[13033] warn: config: SpamAssassin failed to parse line, "/usr/local/bin/dccproc" is not valid for "dcc_path", skipping: dcc_path /usr/local/bin/dccproc
[13033] info: config: dcc_path "/usr/local/bin/dccproc" isn't an executable
[13033] warn: config: SpamAssassin failed to parse line, "/usr/local/bin/dccproc" is not valid for "dcc_path", skipping: dcc_path /usr/local/bin/dccproc

[13033] warn: lint: 2 issues detected, please rerun with debug enabled for more information

I have comment these lines to solve it:

# ifplugin Mail::SpamAssassin::Plugin::DCC
#dcc_path /usr/local/bin/dccproc
#endif

 

From: at: 2010-05-27 12:29:52

Instead of adding the line to the top of the file and commenting out this section, just change it like:

ifplugin Mail::SpamAssassin::Plugin::DCC
dcc_path /usr/bin/dccproc
endif

 That should work.

From: at: 2010-06-03 02:24:07

Double check the permissions, you missed a change somewhere.  It should be under the Mailwatch section.

From: Shoggy at: 2010-05-30 08:56:49

Thanks a lot for this How To. Everything works great except releasing quarantined message in Mailwatch. I have been battling this for over a week but no luck, i dont get the buttons and check box in the message details to release or learn spam. What am i missing, PLS HELP!!

From: iser0073 at: 2010-08-16 08:04:46

I have managed to install these after having some problems:

Install perl:

  aptitude install perl

for DBD::mysql you need mysql dev libraries so install:

  aptitude install libmysqlclient-dev libmysqlclient16-dev

now install DBD::mysql :

  cpan -i DBD::mysql

  cpan -i DBI

This worked for me.

From: Patrick at: 2012-06-22 10:18:47

For those running in to the problems I encountered while executing mysql -p < create.sql; below script runs properly.

 The issue I got were several errors like: ERROR 1064 (42000) at line 19

Alter the script to:

 

-- MySQL dump 8.23
--
-- Host: localhost    Database: mailscanner

-- Server version    3.23.58

--
-- Current Database: mailscanner
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ mailscanner;

USE mailscanner;

--
-- Table structure for table `audit_log`
--

CREATE TABLE audit_log (
  timestamp timestamp NOT NULL,
  user varchar(20) NOT NULL default '',
  ip_address varchar(15) NOT NULL default '',
  action text NOT NULL
) ENGINE=MyISAM;

--
-- Table structure for table `blacklist`
--

CREATE TABLE blacklist (
  id int(11) NOT NULL auto_increment,
  to_address text,
  to_domain text,
  from_address text,
  PRIMARY KEY  (id),
  UNIQUE KEY blacklist_uniq (to_address(100),from_address(100))
) ENGINE=MyISAM;

--
-- Table structure for table `geoip_country`
--

CREATE TABLE geoip_country (
  begin_ip varchar(15) default NULL,
  end_ip varchar(15) default NULL,
  begin_num bigint(20) default NULL,
  end_num bigint(20) default NULL,
  iso_country_code char(2) default NULL,
  country text,
  KEY geoip_country_begin (begin_num),
  KEY geoip_country_end (end_num)
) ENGINE=MyISAM;

--
-- Table structure for table `inq`
--

CREATE TABLE inq (
  id text,
  cdate date default NULL,
  ctime time default NULL,
  from_address text,
  to_address text,
  subject text,
  message text,
  size text,
  priority text,
  attempts text,
  lastattempt text,
  hostname text,
  KEY inq_hostname (hostname(50))
) ENGINE=MyISAM;

--
-- Table structure for table `maillog`
--

CREATE TABLE maillog (
  timestamp timestamp NOT NULL,
  id text,
  size bigint(20) default '0',
  from_address text,
  from_domain text,
  to_address text,
  to_domain text,
  subject text,
  clientip text,
  archive text,
  isspam tinyint(1) default '0',
  ishighspam tinyint(1) default '0',
  issaspam tinyint(1) default '0',
  isrblspam tinyint(1) default '0',
  isfp tinyint(1) default '0',
  isfn tinyint(1) default '0',
  spamwhitelisted tinyint(1) default '0',
  spamblacklisted tinyint(1) default '0',
  sascore decimal(7,2) default '0.00',
  spamreport text,
  virusinfected tinyint(1) default '0',
  nameinfected tinyint(1) default '0',
  otherinfected tinyint(1) default '0',
  report text,
  ismcp tinyint(1) default '0',
  ishighmcp tinyint(1) default '0',
  issamcp tinyint(1) default '0',
  mcpwhitelisted tinyint(1) default '0',
  mcpblacklisted tinyint(1) default '0',
  mcpsascore decimal(7,2) default '0.00',
  mcpreport text,
  hostname text,
  date date default NULL,
  time time default NULL,
  headers text,
  quarantined tinyint(1) default '0',
  KEY maillog_datetime_idx (date,time),
  KEY maillog_id_idx (id(20)),
  KEY maillog_clientip_idx (clientip(20)),
  KEY maillog_from_idx (from_address(200)),
  KEY maillog_to_idx (to_address(200)),
  KEY maillog_host (hostname(30)),
  KEY from_domain_idx (from_domain(50)),
  KEY to_domain_idx (to_domain(50)),
  KEY maillog_quarantined (quarantined)
) ENGINE=MyISAM;

--
-- Table structure for table `mcp_rules`
--

CREATE TABLE mcp_rules (
  rule char(100) NOT NULL default '',
  rule_desc char(200) NOT NULL default '',
  PRIMARY KEY  (rule)
) ENGINE=MyISAM;

--
-- Table structure for table `mtalog`
--

CREATE TABLE mtalog (
  timestamp datetime default NULL,
  host text,
  type text,
  msg_id varchar(20) default NULL,
  relay text,
  dsn text,
  status text,
  delay time default NULL,
  UNIQUE KEY mtalog_uniq (timestamp,host(10),type(10),msg_id,relay(20)),
  KEY mtalog_timestamp (timestamp),
  KEY mtalog_type (type(10))
) ENGINE=MyISAM;

--
-- Table structure for table `outq`
--

CREATE TABLE outq (
  id text,
  cdate date default NULL,
  ctime time default NULL,
  from_address text,
  to_address text,
  subject text,
  message text,
  size text,
  priority text,
  attempts text,
  lastattempt text,
  hostname text,
  KEY outq_hostname (hostname(50))
) ENGINE=MyISAM;

--
-- Table structure for table `sa_rules`
--

CREATE TABLE sa_rules (
  rule varchar(100) NOT NULL default '',
  rule_desc varchar(200) NOT NULL default '',
  PRIMARY KEY  (rule)
) ENGINE=MyISAM;

--
-- Table structure for table `saved_filters`
--

CREATE TABLE saved_filters (
  name text NOT NULL,
  col text NOT NULL,
  operator text NOT NULL,
  value text NOT NULL,
  username text NOT NULL,
  UNIQUE KEY unique_filters (name(20),col(20),operator(20),value(20),username(20))
) ENGINE=MyISAM;

--
-- Table structure for table `spamscores`
--

CREATE TABLE spamscores (
  user varchar(40) NOT NULL default '',
  lowspamscore decimal(10,0) NOT NULL default '0',
  highspamscore decimal(10,0) NOT NULL default '0',
  PRIMARY KEY  (user)
) ENGINE=MyISAM;

--
-- Table structure for table `user_filters`
--

CREATE TABLE user_filters (
  username varchar(60) NOT NULL default '',
  filter text,
  verify_key varchar(32) NOT NULL default '',
  active enum('N','Y') default 'N',
  KEY user_filters_username_idx (username)
) ENGINE=MyISAM;

--
-- Table structure for table `users`
--

CREATE TABLE users (
  username varchar(60) NOT NULL default '',
  password varchar(32) default NULL,
  fullname varchar(50) NOT NULL default '',
  type enum('A','D','U','R','H') default NULL,
  quarantine_report tinyint(1) default '0',
  spamscore tinyint(4) default '0',
  highspamscore tinyint(4) default '0',
  noscan tinyint(1) default '0',
  quarantine_rcpt varchar(60) default NULL,
  PRIMARY KEY  (username)
) ENGINE=MyISAM;

--
-- Table structure for table `whitelist`
--

CREATE TABLE whitelist (
  id int(11) NOT NULL auto_increment,
  to_address text,
  to_domain text,
  from_address text,
  PRIMARY KEY  (id),
  UNIQUE KEY whitelist_uniq (to_address(100),from_address(100))
) ENGINE=MyISAM;

 

 

From: PieterJ at: 2010-05-19 07:04:27

When running  clamav-unofficial-sigs.sh you see this errors

/usr/bin/clamav-unofficial-sigs.sh: line 798: rsync: command not found
/usr/bin/clamav-unofficial-sigs.sh: line 803: rsync: command not found

======================================================================
Sanesecurity Database & GPG Signature File Updates
======================================================================

Sanesecurity mirror site used: www01.masbytes.es 213.194.159.34
Connection to www01.masbytes.es 213.194.159.34 failed - Trying next mirror site.                                                                                                                               ..


Access to all Sanesecurity mirror sites failed - Check for connectivity issues
or signature database name(s) misspelled in the script's configuration file.

You can solve this by installing rsync (aptitude install rsync)

 

From: at: 2010-06-05 03:56:51

Both updated.  Thanks for the catch.

From: PieterJ at: 2010-05-19 18:43:44

After installing SQLGREY you see following errors in /var/log/mail.log:

May 19 16:55:56 smtp sqlgrey: dbaccess: can't connect to DB: Access denied for user 'sqlgrey'@'localhost' (using password: YES)
May 19 16:55:56 smtp sqlgrey: dbaccess: error: couldn't get now() from DB: Access denied for user 'sqlgrey'@'localhost' (using password: YES)
May 19 16:55:56 smtp sqlgrey: fatal: Can't call method "do" on an undefined value at /usr/sbin/sqlgrey line 308.

The SQLGREY db does not exist.

use mysql -p

CREATE USER 'sqlgrey'@'localhost' IDENTIFIED BY 'sqlgreypassword';
CREATE DATABASE IF NOT EXISTS `sqlgrey` ;
GRANT ALL PRIVILEGES ON `sqlgrey` . * TO 'sqlgrey'@'localhost';
FLUSH PRIVILEGES;

edit /etc/sqlgrey/sqlgrey.conf to change db_pass accordenly.


 

From: Ruben Schepers at: 2010-06-02 16:00:13

In ubuntu mysq.sock is located at

/var/run/mysqld/mysqld.sock

not

/tmp/mysql.sock

(Regarding FuzzyOCR configuration)

From: at: 2010-06-05 03:55:02

That is what the guide has..

From: Francisco Maia at: 2010-06-24 10:01:02

Hi,

 I keep getting these errors when testing FuzzyOCR:

Jun 24 10:50:11.147 [14957] dbg: FuzzyOcr: Exec : /usr/bin/giftext /tmp/.spamassassin149534oFg6Btmp/CIMG0980.gif
Jun 24 10:50:11.147 [14957] dbg: FuzzyOcr: Stdout: >/tmp/.spamassassin149534oFg6Btmp/giftext.info
Jun 24 10:50:11.147 [14957] dbg: FuzzyOcr: Stderr: >>/tmp/.spamassassin149534oFg6Btmp/giftext.err
save_execute: Insecure dependency in open while running with -T switch at ../FuzzyOcr/Misc.pm line 92.
save_execute: Insecure dependency in open while running with -T switch at ../FuzzyOcr/Misc.pm line 92.
Jun 24 10:50:11.155 [14953] dbg: FuzzyOcr: Elapsed [14957]: 0.025447 sec. (/usr/bin/giftext: exit 8)
Jun 24 10:50:11.156 [14953] warn: readline() on closed filehandle INFILE at ../FuzzyOcr/Misc.pm line 205.
Jun 24 10:50:11.156 [14953] info: FuzzyOcr: Image is single non-interlaced...
Jun 24 10:50:11.156 [14953] warn: rules: failed to run FUZZY_OCR test, skipping:
Jun 24 10:50:11.156 [14953] warn:  (Insecure dependency in printf while running with -T switch at /etc/spamassassin/FuzzyOcr.pm line 471.
Jun 24 10:50:11.156 [14953] warn: )

I am using the newest version of Ubuntu to install this, so I think this must be related with some incompatibility with a newer Perl version or something like this.

 I tried to install the latest version of FuzzyOCR (3.6.0) and the problem persists.

 Do you have any ideia how to overcome this?

 

 Thanks!

From: Brandon at: 2010-07-03 14:53:17

facing the same issues.  anyone found a solution to this?

From: Joolee at: 2010-11-30 15:47:23

Install version 3.6 of FuzzyOcr (http://fuzzyocr.own-hero.net/wiki/Downloads) and do not alter/uncomment/add the following line

focr_path_bin /usr/local/netpbm/bin:/usr/local/bin:/usr/bin

Works for me this way.

From: Anonymous at: 2011-09-20 21:03:08

Google fuzzyocr untaint

From: Eddo Jansen at: 2010-07-07 06:10:07

Got the same problem here, any help would be appreciated!

Regards,

From: Error at: 2010-07-07 10:54:47

Yep, got them also on the latest release 10.04 Ubuntu server

save_execute: Insecure dependency in open while running with -T switch at /usr/share/perl5/FuzzyOcr/Misc.pm line 92.
save_execute: Insecure dependency in open while running with -T switch at /usr/share/perl5/FuzzyOcr/Misc.pm line 92.

Please help!

From: iser0073 at: 2010-08-16 10:55:14

I'm experiencing the same problems on new Ubuntu 10.04.1 LTS:

save_execute: Insecure dependency in open while running with -T switch at /etc/spamassassin/FuzzyOcr/Misc.pm line 76.
save_execute: Insecure dependency in open while running with -T switch at /etc/spamassassin/FuzzyOcr/Misc.pm line 76.
Aug 16 12:36:21.481 [4259] dbg: FuzzyOcr: Elapsed [4263]: 0.035510 sec. (/usr/bin/giftext: exit 8)
Aug 16 12:36:21.482 [4259] warn: readline() on closed filehandle INFILE at /etc/spamassassin/FuzzyOcr/Misc.pm line 189.
Aug 16 12:36:21.482 [4259] info: FuzzyOcr: Image is single non-interlaced...
Aug 16 12:36:21.482 [4259] warn: rules: failed to run FUZZY_OCR test, skipping:
Aug 16 12:36:21.483 [4259] warn:  (Insecure dependency in printf while running with -T switch at /usr/share/perl5/FuzzyOcr.pm line 469.
Aug 16 12:36:21.483 [4259] warn: )

From: Nathan at: 2010-09-29 17:00:28

I too had this problem and was able to resolve it by performing a reinstall of fuzzyocr and netpbm:

sudo apt-get install fuzzyocr3

Although fuzzyocr was already installed, when I went to install this package it acted like both fuzzyocr and netpbm were not installed.

From: sergrok at: 2010-08-26 03:47:55

mistake in line

 FLUSH PRIVILEDGES;

 it shoud be

 FLUSH PRIVILEGES;

From: sergrok at: 2010-08-26 03:42:24

in sqlgrey.conf you used a line
optmethod = out
but allowed values for optmethod is 'none', 'optin', 'optout'.  in your case value 'out' is equal to 'none'

From: sergrok at: 2010-08-26 03:58:53

CREATE DATABASE /*!32312 IF NOT EXISTS*/ sglgrey;

 database name should be 'sqlgrey', not 'sglgrey'

From: Alvaro Soto at: 2010-11-13 05:16:05

Hello... I had the same problem... here is the solution...

http://headup.sytes.net/?q=node/5

Rocky.... great guide..!!!

From: at: 2010-12-04 00:20:12

Correct, comment out the focr_path line and everything should be fine:

#focr_path_bin

 

From: Patrick at: 2011-08-17 19:07:53

In Step 11, shouldnt touch be:

 touch /etc/sqlgrey/clients_fqdn_whitelist.local && touch /etc/sqlgrey/clients_ip_whitelist.local

From: 011 at: 2010-04-23 02:13:00

I am not sure why only 2000 and 2003 exchange would be of interest here. 2000 version will take any email and then fiind out i fthere is a valid address so script might be of use. 2003 and later exchange will declined delivery of receipient is not valid.

Does this script retreive aliases too?

I am sure that postfix has capability to check if receipient is valid by asking exchenge 2003 and 2007 is email address is valid. I have a note that it is by adding, in main.cf, some check_receipient_address and adress_verify_map configurations

Server like 2000 exchange are rear. Why bother with script?

From: Peter at: 2010-04-26 13:13:44

The point of the Relay Recipients is to drop the connection at the SpamSnake if it is sent to an invalid recipient.  Why bother tying up resources on your mail server checking to see if the recipient is valid?  This is actually a great feature.  I would estimate 30-40% of the messages we receive are sent to invalid recipients.  Using a previous version of this SpamSnake has reduced the load on our mail server dramatically.

From: iser0073 at: 2010-08-16 21:00:23

 the get-iana.sh script is giving me the following problems:

====================================================
aggregate: no prefixes supplied


FOUND THE FOLLOWING RESERVED IP RANGES:
RESERVED_IPS=""


Failed to find reserved IPs.
Possibly the file format has been changed, or I cannot fetch the URL.
====================================================

To fix this problem I had to edit /usr/bin/get-iana.sh file and make the following changes:

  1.  Replace the line :
    IPV4_ADDRESS_SPACE_URL="http://www.iana.org/assignments/ipv4-address-space"
    with this one :
    IPV4_ADDRESS_SPACE_URL="http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.txt"
  2. Replace the line :
    cut -d ' ' -f 1 |\
    with this one :
    awk '{print $1}' |\

now run the script again :
get-iana.sh

This fixed the problem for me.

I have also uploaded my working script, maybe someone can use my version and not have to go through all the trouble, you can grab it from here:
http://ftp.bitfarm.co.za/Pics/iser0073/get-iana.sh

Remember to make the file executable after downloading :
chmod +x /usr/bin/get-iana.sh

Hope this helps a little.

Thanx for a Brilliant tutorial!!