FIX YOUR FIRIGGIN SMTP (Was: Re: Postfix and bogofilter)

Lucas Peet lpeet at eccod.com
Fri Oct 18 22:40:00 CDT 2002


A few months ago, I tried setting up  SpamAssassin on my Postfix box 
very similar to the way jim described below - adding a user, setting up 
the main.cf file with the pipe filter, etc...  I had no effects from the 
issue, and everything worked fine except for the fact that I was 
subscribed to the KCLUG mailing list.  

What was happening, was that when a new message from the list was 
delievered to me, Postfix would pass it off to SA, which would try to 
determine if it was spam or not, modified the headers, then passed the 
email back to Postfix for delievery.  However, because of the headers on 
the emails from the list:

From: owner-kclug at marauder.illiana.net
[mailto:owner-kclug at marauder.illiana.net]On Behalf Of jim
Sent: Friday, October 18, 2002 5:25 AM
To: kclug at kclug.org
Subject: Re: Postfix and bogofilter

Postfix would try to deliver it back to kclug at kclug.org, as that's the address in the To: header.  
The message would get sent back to the list, then try to be delievered to me again, and the process 
would repeat several times.  The outcome was that I was getting NO messages from the list, while 
everyone else was getting up to 5 to 10 copies of each message!  I verified this by checking the 
list's archive on www.kclug.org.

The only was I was able to fix that large annoyance to the list was to disable SA and deal with not 
being able to use it.  It seems that the software was actually operating as it was supposed to, 
just that when SA passed it back to Postfix, Postfix 'forgot' who to really deliever the message 
to, so it sent it back to the list.

Anyone running Postfix and SpamAssassin or Amavisd-new or any other mail filtering program have any 
input / advice on this perplexing issue?  I'd prefer to run SA & Amavisd-new, as that's what I have 
installed, but I suppose I'd go with something else, if it works better.

-Lucas

Jeremy Fowler wrote:

>Have you looked at SpamAssassin with amavisd-new? Postfix filters mail thru a
>direct SMTP connection to localhost port 10024 where Amavisd scans the mail for
>viruses and checks to see if it's spam and then either responds to Postfix with
>a "550: content rejected" or sends it back into postfix on localhost port 10025.
>Since AMaViSD is running as a Daemon, Postfix doesn't need to start a new
>process each time an email comes in, so it's very fast.
>
>http://www.ijs.si/software/amavisd/
>http://spamassassin.org/
>
>my master.cf file:
>
>amavis-smtp	  unix	-	-	y	-	2	smtp
>    -o smtp_data_done_timeout=1200s
>    -o smtp_never_send_ehlo=yes
>    -o disable_dns_lookups=yes
>localhost:10025	  inet	n	-	y	-	-	smtpd
>    -o content_filter=
>    -o local_recipient_maps=
>    -o smtpd_helo_restrictions=
>    -o smtpd_client_restrictions=
>    -o smtpd_sender_restrictions=
>    -o smtpd_recipient_restrictions=permit_mynetworks,reject
>    -o mynetworks=127.0.0.0/8
>
>my main.cf file:
>content_filter = amavis-smtp:localhost:10024
>
>  
>
>>-----Original Message-----
>>From: owner-kclug at marauder.illiana.net
>>[mailto:owner-kclug at marauder.illiana.net]On Behalf Of jim
>>Sent: Friday, October 18, 2002 5:25 AM
>>To: kclug at kclug.org
>>Subject: Re: Postfix and bogofilter
>>
>>
>>I think postfix/bogofilter is working good enough to tell how I did it.  I
>>don't have procmail installed, so this is how I did it without it.  This is
>>on a mailserver that handles mail for a small number of users.
>>
>>1. Get postfix installed and running properly.
>>
>>2. Get bogofilter installed and running properly from the command line.
>>
>>3. Create a user, I used 'filter' as a username.  This user should
>>not be able
>>to log in, but does need a home directory.  I used '/home/filter'.
>>
>>4. Put the bogofilter executable in /usr/sbin
>>
>>5. Put the following script in /usr/sbin
>>
>>#!/bin/bash
>>
>>export PATH=$PATH:/usr/sbin
>>export HOME=/home/filter
>>cd $HOME
>>
>>bogofilter -p | sendmail -i "$@"
>>
>>6. In the master.cf configuration file for postfix, find the line that looks
>>like:
>>
>>smtp	inet   (some other stuff)   	smtpd
>>
>>and add this line after it.
>>
>>	-o content_filter=filter:
>>
>>Be sure to include the ':' at the end of the line.
>>
>>7. Append these lines to the end of the master.cf file:
>>
>>filter    unix  -       n       n       -       -       pipe
>>  user=filter argv=/usr/sbin/filtermail -f ${sender} -- ${recipient}
>>
>>8. Do a 'postfix reload'.
>>
>>9. Now, anything bogofilter recognizes as spam will have a header that looks
>>like:
>>
>>X-Spam-Status: Yes, tests=bogofilter
>>
>>and anything it doesn't think is spam will look like:
>>
>>X-Spam-Status: No, tests=bogofilter
>>
>>10. Even though bogofilter is now filtering your email.  It doesn't know what
>>to look for to distinguish spam from real email.  Create two other mail
>>accounts, one for spam and one for non-spam.  Anytime you receive spam that
>>bogofilter doesn't catch, forward it to the spam address.  Anytime you
>>receive good mail that bogofilter thinks is spam, forward it to the non-spam
>>address.  Periodically, log on to the mail server and go to the directory
>>where the spam mails are.  'su' as the user 'filter' and do a 'cat * |
>>bogofilter -s'.  Delete all the spam files.  Then go to the directory where
>>the good emails are and do a 'cat * | bogofilter -h'.  Then delete all the
>>good emails.  Hopefully, the performance of bogofilter improves over time.
>>
>>Bogofilter has a bug where the last line is sometimes duplicated using the
>>'-p' option.
>>
>>
>>
>>    
>>
>
>
>
>  
>




More information about the Kclug mailing list