SpamAssassin and Postfix

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

SpamAssassin and Postfix

Bob Cohen-3
I'm seeing these entries in my maillog (and others):

        May 19 18:16:41 anduril postfix/qmgr[10162]: warning: connect to  
transport spamfilter: No such file or directory
        May 19 18:16:42 anduril postfix/qmgr[10162]: warning: connect to  
transport spamassassin: Connection refused

which leads me to believe Spamassassin isn't working. Thank you in  
advance for help.

So here's the bullet:

I installed SpamAssassin via cpan and followed the instructions from  
"Indegrated Spamd in Postfix"  (http://wiki.apache.org/spamassassin/IntegratedSpamdInPostfix 
)

I added this:

        smtp      inet  n       -       n       -       -       smtpd
        -o content_filter=spamassassin

and this

        spamassassin       unix  -       n       n       -       -       pipe
    flags=Rq user=nobody argv=/usr/local/bin/spamfilter.sh -oi -f $
{sender} ${recipient}

to my master.cf

I added a user called spamfilter and created this spamfilter.sh

Permissions for spamfilter

[root@anduril postfix]# ls -la /usr/local/bin/spamfilter.sh
-rwxr-xr-x    1 spamfilt spamfilt     1036 May 19 09:09 /usr/local/bin/
spamfilter.sh


spamfilter.sh:

#!/bin/sh

# spamfilter.sh
#
This script redirects mail flagged as spam to a separate account
# You must first create a user account named "spamfilter" to hold the  
flagged mail

SENDMAIL="/usr/sbin/sendmail -i"
SPAMASSASSIN=/usr/bin/spamc
COMMAND="$SENDMAIL $@"
USER=`echo $COMMAND | awk '{ print $NF }' | sed 's/@.*$//'`
NEW_COMMAND=`echo $COMMAND | awk '{ $6 = "spamfilter"; NF = 6; print }'`

# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69

umask 077

OUTPUT="`mktemp /tmp/mailfilter.XXXXXXXXXX`"

if [ "$?" != 0 ]; then
    /usr/bin/logger -s -p mail.warning -t filter "Unable to create  
temporary file."
    exit $EX_TEMPFAIL
fi

# Clean up when done or when aborting.
trap "rm -f $OUTPUT" EXIT TERM

$SPAMASSASSIN -x -E -u $USER > $OUTPUT
return="$?"
if [ "$return" = 1 ]; then
    $NEW_COMMAND < $OUTPUT
    exit $?
elif [ "$return" != 0 ]; then
    /usr/bin/logger -s -p mail.warning -t filter "Temporary  
SpamAssassin failure (spamc returned $return)"
    exit $EX_TEMPFAIL
fi

$SENDMAIL "$@" < $OUTPUT
exit $?

And to add to the fun, spamd keeps on dying.  Any help would be  
appreciated.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SpamAssassin and Postfix

Victor Duchovni
On Mon, May 19, 2008 at 09:22:15PM -0400, Bob Cohen wrote:

> I'm seeing these entries in my maillog (and others):
>
> May 19 18:16:41 anduril postfix/qmgr[10162]: warning: connect to  
> transport spamfilter: No such file or directory
> May 19 18:16:42 anduril postfix/qmgr[10162]: warning: connect to  
> transport spamassassin: Connection refused
>
> which leads me to believe Spamassassin isn't working. Thank you in  
> advance for help.

Wrong conclusion, the transport in question is not even configured in
master.cf, working or otherwise. If it were configure but not functioning,
you'd get connected to the socket, but get a delivery error. You have
not explained how you configured these (presumably pipe(8)) "transports".

    http://www.postfix.org/DEBUG_README.html#mail

--
        Viktor.

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the "Reply-To" header.

To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
<mailto:[hidden email]?body=unsubscribe%20postfix-users>

If my response solves your problem, the best way to thank me is to not
send an "it worked, thanks" follow-up. If you must respond, please put
"It worked, thanks" in the "Subject" so I can delete these quickly.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SpamAssassin and Postfix

Bob Cohen-3

On May 20, 2008, at 12:01 AM, Victor Duchovni wrote:

> you'd get connected to the socket, but get a delivery error. You have
> not explained how you configured these (presumably pipe(8))  
> "transports".


Please forgive my ignorance but is this you are talking about:

spamassassin    unix  -       n       n       -       -       pipe
        flags=Rq user=nobody argv=/usr/local/bin/spamfilter.sh -oi -f $
{sender} ${recipient}

Sorry. I'm a sysadmin by necessity and often find myself in over my  
head.  There is MUCH I do not know about postfix. If this isn't what  
you mean, and you point me in the right direction will happily furnish  
the necessary information once I learn more.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SpamAssassin and Postfix

mouss-2
Bob Cohen wrote:

>
> On May 20, 2008, at 12:01 AM, Victor Duchovni wrote:
>
>> you'd get connected to the socket, but get a delivery error. You have
>> not explained how you configured these (presumably pipe(8))
>> "transports".
>
>
> Please forgive my ignorance but is this you are talking about:
>
> spamassassin    unix  -       n       n       -       -       pipe
>     flags=Rq user=nobody argv=/usr/local/bin/spamfilter.sh -oi -f
> ${sender} ${recipient}


apprently, your postfix can't find this one. did you reload your postfix:
# postfix reload

the other error is about some "spamfilter" transport. it must either be
defined, or not used at all. if the error is for previously queued mail,
you can try
# postsuper -r ALL


>
> Sorry. I'm a sysadmin by necessity and often find myself in over my
> head.  There is MUCH I do not know about postfix. If this isn't what
> you mean, and you point me in the right direction will happily furnish
> the necessary information once I learn more.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SpamAssassin and Postfix

Victor Duchovni
In reply to this post by Bob Cohen-3
On Tue, May 20, 2008 at 07:55:06AM -0400, Bob Cohen wrote:

>
> On May 20, 2008, at 12:01 AM, Victor Duchovni wrote:
>
> >you'd get connected to the socket, but get a delivery error. You have
> >not explained how you configured these (presumably pipe(8))  
> >"transports".
>
>
> Please forgive my ignorance but is this you are talking about:
>
> spamassassin    unix  -       n       n       -       -       pipe
> flags=Rq user=nobody argv=/usr/local/bin/spamfilter.sh -oi -f $
> {sender} ${recipient}

There should be a "--" between "-f ${sender}" and "${recipient}" (just
in case in the future you change the "allow_min_user" parameter).

    spamassassin    unix  -       n       n       -       -       pipe
        flags=Rq user=nobody argv=/usr/local/bin/spamfilter.sh
        -oi -f ${sender} -- ${recipient}

The "allow_min_user" option is there precisely because this is a common
misconfiguration.

Now to your more pressing issue, three possibilities:

    1. The master.cf file is malformed in some fashion, and this
       entry is not actually seen by the master daemon. Check the
       file syntax particularly paying attention to comment lines
       and leading white-space.

    2. The entry is there, but the master(8) daemon has not been
    reloaded recently, and so is not aware of the service yet.

    3. The master(8) daemon has started the service, but it was
       failing repeatedly (perhaps the script does not exist, ...)
       and so was "throttled" (temporarily disabled) and connections
       are failing because the connection queue is full. This
       should be evident from correcponding entries in your logs
       that show the master disabling the service.

    <http://www.postfix.org/DEBUG_README.html#logging>

--
        Viktor.

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the "Reply-To" header.

To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
<mailto:[hidden email]?body=unsubscribe%20postfix-users>

If my response solves your problem, the best way to thank me is to not
send an "it worked, thanks" follow-up. If you must respond, please put
"It worked, thanks" in the "Subject" so I can delete these quickly.
Loading...