You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by Apache Wiki <wi...@apache.org> on 2013/01/09 00:58:00 UTC
[Spamassassin Wiki] Trivial Update of "IntegratedSpamdInPostfix" by jez9999
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Spamassassin Wiki" for change notification.
The "IntegratedSpamdInPostfix" page has been changed by jez9999:
http://wiki.apache.org/spamassassin/IntegratedSpamdInPostfix?action=diff&rev1=36&rev2=37
Comment:
Trying to get the shebang to display
= Integrating SpamAssassin into Postfix using spamd =
-
To integrate SpamAssassin into Postfix, you'll need to pipe incoming e-mail through a script or program that passes the e-mail to SpamAssassin for rewriting, and then either chooses to send it on or discard it (you may wish to discard it, for example, if SpamAssassin reports a very high spam score).
Below are some examples of how to do this using your own script to feed e-mail to SpamAssassin. Aside from the methods below, you can look in the examples folder included with SpamAssassin (located, for example, at /usr/share/doc/spamassassin/examples on Debian installs by default) for other options, like procmail.
@@ -12, +11 @@
This is a simple method to integrate SpamAssassin. All spam e-mail will still come through to your address(es), but it will be clearly marked as spam.
1) Create a bash script to receive e-mail from Postfix and pipe it to SpamAssassin for rewriting. Then forward the rewritten version to Postfix's sendmail implementation:
- {{{
+
- #!/bin/sh
+ {{{#!/bin/sh
- #
+ #
# This script should probably live at /usr/bin/spamfilter.sh
# ... and have 'chown root:root' and 'chmod 755' applied to it.
- #
+ #
# Simple filter to plug SpamAssassin into the Postfix MTA
- #
+ #
# Modified by Jeremy Morton
- #
+ #
# For use with:
# Postfix 20010228 or later
# SpamAssassin 2.42 or later
- #
+ #
# Note: Modify the file locations to match your particular
# server and installation of SpamAssassin.
@@ -45, +44 @@
2) Ensure the newly-created /usr/bin/spamfilter.sh has correct permissions (0755), and is owned by root:root.
3) Modify the /etc/postfix/master.cf file; first, change the first 'smtp' line of the file to:
+
{{{
smtp inet n - - - - smtpd -o content_filter=spamfilter
}}}
Then, add the following (a call to our newly-created spamfilter script) at the end:
+
{{{
spamfilter
unix - n n - - pipe
@@ -61, +62 @@
Now, Postfix should be sending every incoming e-mail through the spamfilter.sh script (which means it's going through SpamAssassin), with the e-mail headers (and maybe the rest of the e-mail, if it's spam) being rewritten before being delivered to the target mailbox. Optionally, you may wish to tweak SpamAssassin's configuration to cause it to rewrite the e-mails in a more useful way (only rewrite spam mail subject but not whole e-mail, add a 'ham' header to give detailed info on even non-spam, etc.)
5) (optional) Tweak SpamAssasin's configuration. Ensure that the below is in /etc/mail/spamassassin/local.cf:
+
{{{
# Rewrite the subject of suspected spam e-mails
rewrite_header Subject *****SPAM*****
@@ -71, +73 @@
# Set the threshold at which a message is considered spam (3 is usually sufficient)
required_score 3.0
}}}
-
== Perl script to discard very obvious spam ==
TODO: describe a similar method to above, but with a Perl script that looks at the rewritten headers and discards spam that is, say, scored higher than 7. That means < 3 is OK, 3-7 is marked as spam but delivered, > 7 is discarded.
@@ -97, +98 @@
}}}
2) Create filter.sh as follows:
- {{{
- #!/bin/sh
+ {{{#!/bin/sh
# filter.sh
#
@@ -231, +231 @@
}}}
and create a `filter.sh` as follows:
- {{{
- #!/bin/bash
+ {{{#!/bin/bash
SENDMAIL="/usr/sbin/sendmail -i"
SPAMASSASSIN=/usr/bin/spamc