Integrating Spam Assassin with Postfix

Talk about any thing that related to networking, running servers with *nux.

Moderator: kalinga

Integrating Spam Assassin with Postfix

Postby kalinga » Mon Jan 09, 2006 2:02 pm

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.
kalinga
Site Admin
 
Posts: 209
Joined: Fri Oct 14, 2005 3:19 pm
Location: Sri Lanka

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

Postby delleray » Thu Feb 16, 2006 4:38 pm

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.
delleray
 
Posts: 5
Joined: Thu Feb 16, 2006 4:34 pm

Postby kalinga » Thu Feb 16, 2006 4:54 pm

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.
kalinga
Site Admin
 
Posts: 209
Joined: Fri Oct 14, 2005 3:19 pm
Location: Sri Lanka

3.1 spamassassin

Postby delleray » Thu Feb 16, 2006 4:58 pm

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.
delleray
 
Posts: 5
Joined: Thu Feb 16, 2006 4:34 pm

Postby kalinga » Thu Feb 16, 2006 9:27 pm

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....
kalinga
Site Admin
 
Posts: 209
Joined: Fri Oct 14, 2005 3:19 pm
Location: Sri Lanka

SA 3.1 and perl

Postby delleray » Thu Feb 16, 2006 9:42 pm

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.
delleray
 
Posts: 5
Joined: Thu Feb 16, 2006 4:34 pm

Postby kalinga » Thu Feb 16, 2006 10:01 pm

great ! :)
kalinga
Site Admin
 
Posts: 209
Joined: Fri Oct 14, 2005 3:19 pm
Location: Sri Lanka

use vi transport failed...

Postby delleray » Fri Feb 17, 2006 2:08 am

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?...
delleray
 
Posts: 5
Joined: Thu Feb 16, 2006 4:34 pm

Postby kalinga » Fri Feb 17, 2006 7:56 am

try this

Code: Select all
chown acspamfilter:root /usr/local/bin/acspamfilter
kalinga
Site Admin
 
Posts: 209
Joined: Fri Oct 14, 2005 3:19 pm
Location: Sri Lanka

Postby delleray » Fri Feb 17, 2006 1:31 pm

will try when system quiet (never)
]but the filter is run as that user so that shouldn't matter surely?
d
delleray
 
Posts: 5
Joined: Thu Feb 16, 2006 4:34 pm

Postby kalinga » Fri Feb 17, 2006 1:44 pm

the user does matter, if not he cant reat the file. so you will get the error saying file not found.
kalinga
Site Admin
 
Posts: 209
Joined: Fri Oct 14, 2005 3:19 pm
Location: Sri Lanka

New Update

Postby kalinga » Thu Mar 16, 2006 12:23 pm

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
kalinga
Site Admin
 
Posts: 209
Joined: Fri Oct 14, 2005 3:19 pm
Location: Sri Lanka


Return to Linux - Networking

Who is online

Users browsing this forum: No registered users and 0 guests

cron