You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by J Rangi <jp...@aleks.com> on 2006/06/08 01:43:33 UTC

Spam assassin and postfix..

Hello,
I configured sapmassassin with postfix.
Sapmassassin version is   spamassassin-3.0.3-4.fc4
Here is my spam filter script..

******************************************************
*[root@localmail log]# cat /usr/local/bin/spamfilter
#variables
SENDMAIL="/usr/sbin/sendmail.postfix -i"
EGREP=/bin/egrep
# Exit codes from <sysexits.h>
EX_UNAVAILABLE=69
# Number of *'s in X-Spam-level header needed to sideline message:
# (Eg. Score of 5.5 = "*****" )
SPAMLIMIT=5
# Clean up when done or when aborting.
trap "rm -f /var/tempfs/out.$$" 0 1 2 3 15
# Pipe message to spamc
cat | /usr/bin/spamc -u spamfilter > /var/tempfs/out.$$

if $EGREP -q "^X-Spam-Level: \*{$SPAMLIMIT,}" < /var/tempfs/out.$$
  then
## Change the Email address where you want your spam to get fwd to
  $SENDMAIL -f jaitest@aleks.com < /var/tempfs/out.$$
  else
    ###$SENDMAIL "$@" < /var/tempfs/out.$$
    $SENDMAIL $@ < /var/tempfs/out.$$
  fi
# Postfix returns the exit status of the Postfix sendmail command.
exit $? *
******************************

I made these changes in master.cf file..
Changed this line by adding "-o content_filter=spamfilter:dummy" to the 
default
*smtp      inet  n       -       n       -       -       smtpd -o 
content_filter=spamfilter:dummy *
Added next two lines..
*spamfilter unix -       n       n       -       -       pipe
  flags=Rq user=spamfilter argv=/usr/local/bin/spamfilter -f ${sender} 
-- ${recipient} *

Once postfix reloaded I can see that mails are being processed by 
spamfilter.
But for some mails I get these kind of error in the log file and user 
receives mail from MAILER-DAEMON
Can some please tell me why we get these only for some mail and how to 
get rid of this problem.

Jun  7 10:51:44 localmail spamd[14011]: spamd: identified spam 
(17.8/6.8) for spamfilter:7715 in 2.3 seconds, 1753 bytes.
Jun  7 10:51:44 localmail spamd[14011]: spamd: result: Y 17 - 
MSGID_FROM_MTA_HEADER,MSGID_FROM_MTA_ID,RCVD_IN_BL_SPAMCOP_NET,UNPARSEABLE_RELAY,URIBL_AB_SURBL,URIBL_JP_SURBL,URIBL_OB_SURBL,URIBL_SBL,URIBL_SC_SURBL,URIBL_WS_SURBL 
scantime=2.3,size=1753,user=spamfilter,uid=7715,required_score=6.8,rhost=localhost.localdomain,raddr=127.0.0.1,rport=33304,mid=<20...@ip26.aleks.com>,autolearn=no 

Jun  7 10:51:44 localmail postfix/sendmail[14909]: fatal: Recipient 
addresses must be specified on the command line or via the -t option
Jun  7 10:51:44 localmail spamd[14009]: prefork: child states: II
Jun  7 17:51:45 localmail postfix/postdrop[14910]: warning: stdin: 
unexpected EOF in data, record type 78 length 85
Jun  7 10:51:45 localmail postfix/postdrop[14910]: fatal: uid=7715: 
malformed input
Jun  7 10:51:46 localmail postfix/pipe[13865]: DA97E60EB2: 
to=<th...@gateway3.aleks.com>, relay=spamfilter, delay=5, 
status=bounced (command line usage error. Command output: 
sendmail.postfix: fatal: Recipient addresses must be specified on the 
command line or via the -t option postdrop: warning: stdin: unexpected 
EOF in data, record type 78 length 85 postdrop: fatal: uid=7715: 
malformed input )
Jun  7 10:51:46 localmail postfix/cleanup[13864]: 6AF4562F46: 
message-id=<20...@localmail.lan.aleks.com>
Jun  7 10:51:46 localmail postfix/qmgr[13851]: 6AF4562F46: from=<>, 
size=3990, nrcpt=1 (queue active)
Jun  7 10:51:46 localmail postfix/qmgr[13851]: DA97E60EB2: removed
Jun  7 10:51:46 localmail postfix/smtp[14867]: 6AF4562F46: 
to=<wl...@megapath.net>, relay=mail.aleks.com[216.34.240.136], 
delay=0, status=sent (250 2.0.0 k57HpkM18899 Message accepted for delivery)
Jun  7 10:51:46 localmail postfix/qmgr[13851]: 6AF4562F46: removed
Jun  7 10:51:48 localmail postfix/smtpd[13861]: connect from 
ip26.aleks.com[216.34.240.160]
Jun  7 10:51:48 localmail postfix/smtpd[13861]: 5F35C60EB2: 
client=ip26.aleks.com[216.34.240.160]
Jun  7 10:51:48 localmail postfix/cleanup[13913]: 5F35C60EB2: 
message-id=<20...@ip26.aleks.com>




Re: Spam assassin and postfix..

Posted by Bill Randle <bi...@neocat.org>.
On Wed, 2006-06-07 at 16:43 -0700, J Rangi wrote:
> Hello,
> I configured sapmassassin with postfix.
> Sapmassassin version is   spamassassin-3.0.3-4.fc4
> Here is my spam filter script..
> 
> ******************************************************
> *[root@localmail log]# cat /usr/local/bin/spamfilter
> #variables
> SENDMAIL="/usr/sbin/sendmail.postfix -i"
> EGREP=/bin/egrep
> # Exit codes from <sysexits.h>
> EX_UNAVAILABLE=69
> # Number of *'s in X-Spam-level header needed to sideline message:
> # (Eg. Score of 5.5 = "*****" )
> SPAMLIMIT=5
> # Clean up when done or when aborting.
> trap "rm -f /var/tempfs/out.$$" 0 1 2 3 15
> # Pipe message to spamc
> cat | /usr/bin/spamc -u spamfilter > /var/tempfs/out.$$
> 
> if $EGREP -q "^X-Spam-Level: \*{$SPAMLIMIT,}" < /var/tempfs/out.$$
>   then
> ## Change the Email address where you want your spam to get fwd to
>   $SENDMAIL -f jaitest@aleks.com < /var/tempfs/out.$$
>   else
>     ###$SENDMAIL "$@" < /var/tempfs/out.$$
>     $SENDMAIL $@ < /var/tempfs/out.$$
>   fi
> # Postfix returns the exit status of the Postfix sendmail command.
> exit $? *
> ******************************
> 
> I made these changes in master.cf file..
> Changed this line by adding "-o content_filter=spamfilter:dummy" to the 
> default
> *smtp      inet  n       -       n       -       -       smtpd -o 
> content_filter=spamfilter:dummy *
> Added next two lines..
> *spamfilter unix -       n       n       -       -       pipe
>   flags=Rq user=spamfilter argv=/usr/local/bin/spamfilter -f ${sender} 
> -- ${recipient} *
> 
> Once postfix reloaded I can see that mails are being processed by 
> spamfilter.
> But for some mails I get these kind of error in the log file and user 
> receives mail from MAILER-DAEMON
> Can some please tell me why we get these only for some mail and how to 
> get rid of this problem.
> 
> Jun  7 10:51:44 localmail spamd[14011]: spamd: identified spam 
> (17.8/6.8) for spamfilter:7715 in 2.3 seconds, 1753 bytes.
> Jun  7 10:51:44 localmail spamd[14011]: spamd: result: Y 17 - 
> MSGID_FROM_MTA_HEADER,MSGID_FROM_MTA_ID,RCVD_IN_BL_SPAMCOP_NET,UNPARSEABLE_RELAY,URIBL_AB_SURBL,URIBL_JP_SURBL,URIBL_OB_SURBL,URIBL_SBL,URIBL_SC_SURBL,URIBL_WS_SURBL 
> scantime=2.3,size=1753,user=spamfilter,uid=7715,required_score=6.8,rhost=localhost.localdomain,raddr=127.0.0.1,rport=33304,mid=<20...@ip26.aleks.com>,autolearn=no 
> 
> Jun  7 10:51:44 localmail postfix/sendmail[14909]: fatal: Recipient 
> addresses must be specified on the command line or via the -t option
> Jun  7 10:51:44 localmail spamd[14009]: prefork: child states: II
> Jun  7 17:51:45 localmail postfix/postdrop[14910]: warning: stdin: 
> unexpected EOF in data, record type 78 length 85
> Jun  7 10:51:45 localmail postfix/postdrop[14910]: fatal: uid=7715: 
> malformed input
> Jun  7 10:51:46 localmail postfix/pipe[13865]: DA97E60EB2: 
> to=<th...@gateway3.aleks.com>, relay=spamfilter, delay=5, 
> status=bounced (command line usage error. Command output: 
> sendmail.postfix: fatal: Recipient addresses must be specified on the 
> command line or via the -t option postdrop: warning: stdin: unexpected 
> EOF in data, record type 78 length 85 postdrop: fatal: uid=7715: 
> malformed input )


The clue is in the error log. It says you must use "-t" or specify the
recipient on the sendmail command line. In the case the message is
detected as spam, you do this:
	$SENDMAIL -f jaitest@aleks.com < /var/tempfs/out.$$

There's no -t and no recipient. The -f option is the "from" part. I
suspect you want to send spam to jaitest@aleks.com, in which case
try something like this:
	$SENDMAIL -f $2 jaitest@aleks.com < /var/tempfs/out.$$

$2 should be the sender, as passed into the filter script.

Rather than calling spamc on each message, you might also consider
a daemon solution which will reduce the overhead and startup delay
time. Very helpful if processing a lot of mail. I use amavisd-new
and have it run clamd before spamassassin. There are others that
have been mentioned in this mailing list, as well.

	-Bill