Page 1 of 1

Integrating Spam Assassin with Postfix

PostPosted: Mon Jan 09, 2006 2:02 pm
by kalinga
1. Install SpamAssassin

if you need any help visit
http://spamassassin.apache.org/

add a user call spamfilter with out shell.

Code: Select all
adduser spamfilter -s /sbin/nologin


2. Setup Postfix

edit the master.cf

add the line

Code: Select all
spamfilter unix - n n - - pipe
  flags=Rq user=spamfilter argv=/usr/local/bin/spamfilter -f ${sender} -- ${recipient}



edit the SMTP as

Code: Select all

smtp      inet  n       -       n       -       -       smtpd
        -o content_filter=spamfilter:dummy



now creat a file call

/usr/local/bin/spamfilter

eg

Code: Select all
vi /usr/local/bin/spamfilter



Code: Select all

#!/bin/bash

/usr/bin/spamc | /usr/sbin/sendmail.postfix -i "$@"

exit $?



now chnage the owner of the file to spamfilter

Code: Select all
chown spamfilter /usr/local/bin/spamfilter


now set permisson as

Code: Select all
chmod 755 /usr/local/bin/spamfilter


thats it your done.


now reload postfix

Code: Select all
/etc/init.d/postfix reload



thats it... your done.

/usr/bin/spamc does not exist on 3.1.0 install on FC4

PostPosted: Thu Feb 16, 2006 4:38 pm
by delleray
Hi

Just 'upgraded' from 2.x on Fc4 to 3.1.0

de-installed old and did a clean install of 3.1.0 from the fc4 rpm.

it does not install an executable at /usr/bin/spamc since it is a perl based app.

so the script would not work.

d.

PostPosted: Thu Feb 16, 2006 4:54 pm
by kalinga
u can you use the perl cpan shell to install the uptodate SpamAssasin or just use the

/usr/bin/spamassassin

insted of the

/usr/bin/spamc

make sure the path is right.

let me know if you need any help.

3.1 spamassassin

PostPosted: Thu Feb 16, 2006 4:58 pm
by delleray
K.

The clean install of 3.1 does not install any binaries as it is a perl module.

so there is no /usr/bin entries.

d.

PostPosted: Thu Feb 16, 2006 9:27 pm
by kalinga
Hi,

just did a test with FC4 without using the FC4's RPM;s just using the cpan shell,

Code: Select all
perl -MCPAN -e shell

install MD5 LWP MIME::Base64 Mail::Internet Archive::Tar Archive::Zip IO::Wrap IO::Stringy Unix::Syslog MIME::Base64 MIME::Words MIME::Head MIME::Body MIME::Entity MIME::Parser Net::SMTP Net::DNS Net::Ping Net::Server Net::Server::PreForkSimple Convert::TNEF Convert::UUlib MIME::Decoder::Base64 MIME::Decoder::Binary MIME::Decoder::Gzip64 MIME::Decoder::NBit MIME::Decoder::QuotedPrint MIME::Decoder::UU Time::HiRes Digest::SHA1 Digest::Nilsimsa Getopt::Long File::Copy Bit::Vector Date::Calc Mail::SpamAssassin




it works like a charm....

SA 3.1 and perl

PostPosted: Thu Feb 16, 2006 9:42 pm
by delleray
Now I have found that the system was upgraded with YUM
and to get 3.1 only the perl version was taken hence no binaries.

installing from RPM pbone net picked up the 3.1.0 fc4 and that comes with the perl stuff so the binaries are there.

currently using procmail it works; once client traffic drops will do via content filtering.

tks
d.

PostPosted: Thu Feb 16, 2006 10:01 pm
by kalinga
great ! :)

use vi transport failed...

PostPosted: Fri Feb 17, 2006 2:08 am
by delleray
unfortunately it didn't work
(am using acspamfilter instead of spamfilter

Feb 16 20:23:44 satwise-ac pipe[5641]: fatal: pipe_comand: execvp /usr/local/bin/acspamfilter: No such file or directory

but there is
> ls /usr/local/bin/spamfilter -l
-rwxr-xr-x 1 acspamfilter 511 74 Feb 16 20:00 /usr/local/bin/acspamfilter

and i changed master.cf
##rje##
##smtp inet n - n - - smtpd
smtp inet n - n - - smtpd
-o content_filter=acspamfilter:dummy
##rje end##
....
##rje##
acspamfilter unix - n n - - pipe
flags=Rq user=acspamfilter argv=/usr/local/bin/acspamfilter -f ${sender} -- ${recipient}
##rjeend##


comments?...

PostPosted: Fri Feb 17, 2006 7:56 am
by kalinga
try this

Code: Select all
chown acspamfilter:root /usr/local/bin/acspamfilter

PostPosted: Fri Feb 17, 2006 1:31 pm
by delleray
will try when system quiet (never)
]but the filter is run as that user so that shouldn't matter surely?
d

PostPosted: Fri Feb 17, 2006 1:44 pm
by kalinga
the user does matter, if not he cant reat the file. so you will get the error saying file not found.

New Update

PostPosted: Thu Mar 16, 2006 12:23 pm
by kalinga
Here's the UpdatedVer of the Script that will Quarantine SPAM email to a defrant email accout.

http://onetforum.com/fourm/viewtopic.php?p=63#63