Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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,
     * 0.0 URIBL_RED Contains an URL listed in the URIBL redlist
     * [URIs:]
     * 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
     * [ listed in]
     * 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
     * [ listed in]
     * 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:]
     * 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

share|improve this question
up vote 0 down vote accepted

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.

share|improve this answer

In a similar situation, we are using postfix/dovecot IMAP/dovecot LDA. All mail is processed by Sieve module in Dovecot LDA. Mail having the necessary spam headers are posted into a "spam" box by help of a global sieve rule in Dovecot LDA.

share|improve this answer

Procmail would do this easily, in fact there's a "recipe" on the SpamAssassin site.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.