Linux – Moving automatically spam messages to a folder in Postfix

linuxpostfixprocmailspamassassinsquirrelmail

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

Best Answer

I'm using a fairly similar setup (Postfix/SpamAssassin with amavisd-new/Dovecot) and I use maildrop as a delivery agent with filtering capabilities. Why not procmail? Simply because I find maildrop easier to live with. In the end it accomplishes the same or similar tasks. The first rule in pretty much any maildrop filter file I set up checks if X-Spam-Flag is set and if so, moves the email into the Spam folder.

I would recommend against using a squirrelmail rule to move Spam; you don't know if you or your users also want to use another client besides squirrelmail. Given that one of IMAP's great advantages is that you can have multiple clients have the same view of the same Inbox, I'd go for a setup that preserves this advantage, which means using a separate delivery agent/filter.