svlug-using_spamassasin_with_postfix

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



Date: 24 Sep 2002 10:41:15 -0700
From: Florin Andrei <florin@sgi.com>
To: svlug@lists.svlug.org
Subject: Re: [svlug] SpamAssassin + Postfix - the solution

On Thu, 2002-09-19 at 13:36, Florin Andrei wrote:
> 
> Since you brought this up - anyone has a "magic recipe" :-) for making
> SpamAssassin work with Postfix?

Ok, here's what works for me.

There are several recipes on the Internet to interface Postfix and
SpamAssassin, but most of them are based on the scripting content
filters in Postfix.
This solution, no doubt very simple, has a major drawback: for each and
every message you have to fork()/exec() a large external program, like
procmail or the like.
This doesn't work on busy systems. It's also not the best solution for
my tiny PII/266 home server - just seeing Apache scrambling for
resources whenever i get more than two visitors on my website is
frightening. :-)

What i wanted was a "daemonized" content filter. SpamAssassin indeed
comes with spamd, which was created for this kind of purposes.
Problem is, spamd uses stdin/stdout to talk to the outer world, and i'm
not sure how to interface that (as a daemon) with Postfix. But i do know
how to interface a daemon listening on a TCP port with Postfix, if only
SpamAssassin had that.

The solution is spampd:

http://www.worlddesign.com/index.cfm/rd/mta/spampd.htm

It is a spamd replacement. It does the same things as spamd, but instead
it talks via tcp:25. It is, in fact, a small MTA.
It comes with a nifty RedHat-style init.d script, and since it's
actually a tiny Perl script, it's quite configurable.

The idea is to run spampd on localhost:10025, make Postfix route all
messages through that (as a content filter), and tell spampd to route
messages back to Postfix after spamassassinating them.

Installing spampd is quite simple. When running it, most likely you'll
get into all kind of missing Perl modules. Thanks to my magic CPAN2RPM
script, i was able to RPMify all of them and install as packages.
Of course, you need to install SpamAssassin before that.

Then run spampd this way:

spampd --port=10025 --relayhost=127.0.0.1:10026

Now tell Postfix to relay all messages through spampd; edit main.cf and
add this line:

content_filter = smtp:[localhost]:10025

And now we have to provide the Postfix listener on 10026 to get back the
messages scanned by spampd; edit master.cf and add these lines:

localhost:10026 inet n - n - - smtpd
        -o content_filter=
        -o local_recipient_maps=
        -o myhostname=localhost

Restart Postfix and that's it!

Credits go to Scott Cooper (scott_at_iguana2.com) for coming up with
this solution.

===

Date: 24 Sep 2002 14:36:14 -0700
From: Florin Andrei <florin@sgi.com>
To: svlug@lists.svlug.org
Subject: Re: [svlug] SpamAssassin + Postfix - the solution

On Tue, 2002-09-24 at 10:41, Florin Andrei wrote:
> 
> Problem is, spamd uses stdin/stdout to talk to the outer world, and i'm
> not sure how to interface that (as a daemon) with Postfix. But i do know
> how to interface a daemon listening on a TCP port with Postfix, if only
> SpamAssassin had that.

Correction: spamd talks via a TCP socket.
Problem is, it's not using SMTP, but it's own fixer-upper protocol, and
Postfix wants SMTP.

Otherwise, i'm killig spam now successfully. :-)

===

the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu