postfix-users October 2010 archive
Main Archive Page > Month Archives  > postfix-users archives
postfix-users: Re: Scanning Mails Relayed via Postfix Server/Spa

Re: Scanning Mails Relayed via Postfix Server/Spamassassin

From: Nicholas Sideris <n.sideris_at_nospam>
Date: Mon Oct 04 2010 - 13:46:09 GMT
To: postfix users <postfix-users@postfix.org>

Hi,

The first solution is amavis. But if you don't want to install amavis, there's another trick using shell scripts

Save the script below to some file which is accessible in your $PATH for my example it is saved as postspam
#!/bin/sh
TEMPFILE=$$.$RANDOM.$RANDOM
SPAMKLVL=11
cat > /tmp/$TEMPFILE
SPAMLEVL=`cat /tmp/$TEMPFILE | /usr/bin/spamc --check | sed 's/\/.*$//' | sed 's/\..*$//'`
if (("$SPAMLEVL" < "$SPAMKLVL"))
  then cat /tmp/$TEMPFILE | /usr/bin/spamc | /usr/sbin/sendmail -i "$@"
       echo "$@" >> /tmp/maillist
fi
rm /tmp/$TEMPFILE

Create an isolated user for the process e.g spamdu

Then modify your master.cf as following:
postspam unix - n n - - pipe
   flags=Rq user=spamdu argv=/server/bin/postspam -f ${sender} -- ${recipient}
#....
smtp inet n - n - - smtpd
  -o content_filter=postspam:dummy

Configure spamassassin for user spamdu and train it appropriately (I am using MySQL databases for this anyway)

Now it should be ok, plus the fact that the script can kill the spam of a level above (beware not to use decimals)

Best Regards
Nick

(Hope it would help you)

On Oct 4, 2010, at 4:05 PM, Cimoni Enwis Ogwujiakwu wrote:

> Hello Donovan
> Thanks for your response
> postfconf -n display below
> # postconf -n
> command_directory = /usr/local/sbin
> config_directory = /usr/local/etc/postfix
> daemon_directory = /usr/local/libexec/postfix
> data_directory = /var/db/postfix
> debug_peer_level = 2
> html_directory = /usr/local/share/doc/postfix
> inet_interfaces = all
> mail_owner = postfix
> mailq_path = /usr/local/bin/mailq
> manpage_directory = /usr/local/man
> mydomain = example.com
> myhostname = relay.example.com
> mynetworks = 192.168.15.0/8, 127.0.0.0/8
> newaliases_path = /usr/local/bin/newaliases
> queue_directory = /var/spool/postfix
> readme_directory = /usr/local/share/doc/postfix
> sample_directory = /usr/local/etc/postfix
> sendmail_path = /usr/local/sbin/sendmail
> setgid_group = maildrop
> soft_bounce = no
> unknown_local_recipient_reject_code = 550
>
> Cimoni Enwis Ogwujiakwu
>
> --- On Thu, 9/30/10, donovan jeffrey j <donovan@beth.k12.pa.us> wrote:
>
> From: donovan jeffrey j <donovan@beth.k12.pa.us>
> Subject: Re: Scanning Mails Relayed via Postfix Server/Spamassassin
> To: "Cimoni Enwis Ogwujiakwu" <ogwujiakwuenwis@yahoo.com>
> Cc: postfix-users@postfix.org
> Date: Thursday, September 30, 2010, 3:25 PM
>
>
> On Sep 30, 2010, at 8:16 AM, Cimoni Enwis Ogwujiakwu wrote:
>
> > Hello,
> > I have setup a postfix server for scanning mails for spam relayed through it and I have redirected all port 25 traffic through it from my firewall but when I try sending mails through
> > telnet for example smtp.gmail.com 25
> > I still get through without seeing any transcation on the postfix server and no scanning by the spam assassin.
> > What I am getting wrong here.
> >
> >
>
> postconf -n
>
> SA doesn't run on port 25 usually. in main.cf you should have a content_filter statement.
>
> eg;
> content_filter = smtp-amavis:[127.0.0.1]:10024
>
>