Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 11-05-2003, 07:08 AM   #1
Registered: Apr 2002
Location: New York, USA
Distribution: Redhat 7.2, 9.0 Slackware 9.1
Posts: 428

Rep: Reputation: 30
Sorting mail into folders?

I have just gotten spamassassin working on one of my servers and it is working great, I have it for right now just changing the title of the messages to [SPAM] so I can see which ones it is marking. What I would like to do now is have any messages it marks as spam be put into a spam imap folder. All the users on this server are using squirrelmail to check their mail so haveing a spam folder would be ideal. My problem is I do not know where to start on doing that, which program would do the sorting?

These are the programs I am useing for mail


At first I thought that spamassassin should do the sorting into different folders but now I don't think it is its job but what program is it that would do that?

Can any of the above programs sort any messages with [SPAM] in the title to a spam mailbox for that user? And how would I do that?
Old 11-05-2003, 07:38 AM   #2
Registered: Aug 2003
Location: Edinburgh, Scotland
Distribution: Gentoo
Posts: 246

Rep: Reputation: 30
At some point your setup will call procmail. Edit your ~/.procmailrc file to a spam folder when the headers match 'Subject: .*\[SPAM\].*'. You will need to read the procmailrc man page as I can't remember the precise syntax at the moment.
Old 11-07-2003, 09:43 AM   #3
Registered: Apr 2002
Location: New York, USA
Distribution: Redhat 7.2, 9.0 Slackware 9.1
Posts: 428

Original Poster
Rep: Reputation: 30
Thank you for your response, I have spent the last couple of days trying to get it all to work together. I finally got it to work and wanted to reply back with how I did it as this seems to not be very documented on the web.

I setup my mail server very similar to the guide here:

I did the spamassassin and clam antivirus checking, this was working very good for finding the messages that were spam but I wanted to filter any message that started with [SPAM] into a spam imap folder.

I am useing vpopmail so it is not the regular setup but I used procmail like was said above and put the following two files in.


The contents were:
### Spam Assassin
| /usr/bin/spamassassin -P


### Toss Spam into a Folder
* ^Subject:.*\[SPAM\].*

### Deliver the rest into Maildir normally
And then I called that file from the following file:

The contents of that file were:
| preline procmail -t /home/vpopmail/domains/
After I made those two files it now sorts all the messages marked as spam to the spam imap folder. Now my next project is to delete any messages that are over 7 days old in that spam box from a cron job. If I get that I will post that here as well.
Old 11-07-2003, 10:02 AM   #4
Registered: Oct 2003
Distribution: Debian/unstable
Posts: 85

Rep: Reputation: 15
If you're using courier-imap, you're probably also using courier maildrop? If so, maildrop has a builtin facility for filtering based on per-Maildir config files.

I have a similar setup - postfix+courier-imap+courier-maildrop, and several of my users use my squirrelmail interface. (I don't really have any custom spam checkers, because my global maildrop filter catches 99% of the spam anyway.)
Old 11-07-2003, 10:20 AM   #5
Registered: Apr 2002
Location: New York, USA
Distribution: Redhat 7.2, 9.0 Slackware 9.1
Posts: 428

Original Poster
Rep: Reputation: 30
I may find a better way of doing it, but for now that will do the job, I am going to program a custom interface later where users can set their spam settings, and a bunch of stuff but until then I will just do it the way I said above.

This project started out as just scanning for virus's but when I was looking it looked like I could also do spam filtering with just a little more setup so I went for the whole thing.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to backup / restore mail folders i_s Linux - General 1 04-23-2005 02:05 PM
procmail mail sorting FLOODS Linux - Networking 1 11-26-2004 09:12 PM
Mozzilla mail erased my folders griev Linux - Newbie 1 09-06-2004 12:45 PM
Sorting mp3s into folders by ID3 tags? deadjoebob Linux - Software 0 03-07-2004 12:21 PM
sorting my mail after fetchmail has got it. kudos Linux - General 3 01-04-2003 04:06 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:04 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration