Moving automatically spam messages to a folder in Postfix

Posted by cad on Server Fault See other posts from Server Fault or by cad
Published on 2010-04-24T11:16:10Z Indexed on 2010/04/24 11:23 UTC
Read the original article Hit count: 500

Hi

My problem is that I want to automatically to move spam messages to a folder and not sure how.

I have a linux box giving email access. MTA is Postfix, IMAP is Courier. As webmail client I use Squirrelmail. To filter SPAM I use Spamassassin and is working ok.

Spamassasin is overwriting subjects with [--- SPAM 14.3 ---] Viagra... Also is adding headers:

    X-Spam-Flag: YES
    X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on xxxx
    X-Spam-Level: **************
    X-Spam-Status: Yes, score=14.3 required=2.0 tests=BAYES_99,
     DATE_IN_FUTURE_24_48,HTML_MESSAGE,MIME_HTML_ONLY,RCVD_IN_PBL,
     RCVD_IN_SORBS_WEB,RCVD_IN_XBL,RDNS_NONE,URIBL_RED,URIBL_SBL autolearn=no
     version=3.2.5
    X-Spam-Report:
     * 0.0 URIBL_RED Contains an URL listed in the URIBL redlist
     * [URIs: myimg.de]
     * 3.5 BAYES_99 BODY: Bayesian spam probability is 99 to 100%
     * [score: 1.0000]
     * 0.9 RCVD_IN_PBL RBL: Received via a relay in Spamhaus PBL
     * [113.170.131.234 listed in zen.spamhaus.org]
     * 3.0 RCVD_IN_XBL RBL: Received via a relay in Spamhaus XBL
     * 0.6 RCVD_IN_SORBS_WEB RBL: SORBS: sender is a abuseable web server
     * [113.170.131.234 listed in dnsbl.sorbs.net]
     * 3.2 DATE_IN_FUTURE_24_48 Date: is 24 to 48 hours after Received: date
     * 0.0 HTML_MESSAGE BODY: HTML included in message
     * 1.5 MIME_HTML_ONLY BODY: Message only has text/html MIME parts
     * 1.5 URIBL_SBL Contains an URL listed in the SBL blocklist
     * [URIs: myimg.de]
     * 0.1 RDNS_NONE Delivered to trusted network by a host with no rDNS

I want to automatically to move spam messages to a folder. Ideally (not sure if possible) only to move messages with puntuation 5.0 or more to folder.. spam between 2.0 and 5.0 I want to be stored in Inbox. (I plan later to switch autolearn on)

After reading a lot in procmail, postfix and spamassasin sites and googling a lot (lot of outdated howtos) I found two solutions but not sure which is the best or if there is another one:

  1. Put a rule in squirrelmail (dirty solution?)
  2. Use Procmail

Which is the best option? Do you have any updated howto about it? Thanks

© Server Fault or respective owner

Related posts about postfix

Related posts about procmail