Author Topic: Filtering Spam to "Junk" Folder?  (Read 23349 times)

Offline Eleventeen

  • Newbie
  • *
  • Posts: 5
Filtering Spam to "Junk" Folder?
« on: September 27, 2007, 10:42:21 PM »
Hi, I'm using Mailscanner to scan my email for spam, but I'm wondering how I would go about moving those marked messages into the Junk folder (or any folder for that matter)? Thanks for any help you guys can give! :)

Offline timelord

  • Jr. Member
  • **
  • Posts: 15
Re: Filtering Spam to "Junk" Folder?
« Reply #1 on: September 27, 2007, 11:32:47 PM »
I have MailScanner too, I use it with postfix and dovecot and all my user accounts are virtual (stored in MySQL)

I presume your current configuration is working, right ? What you need is a sieve modul for dovecot

Mail filtering is done by dovecot's deliver + sieve, that's why you have to set up your postfix to use dovecot's deliver for mail delivery and set up your dovecot to use sieve plugin.

Here are the most important parts of my configuration:

Postfix

master.cf

Code: [Select]
# ...
dovecot  unix -   n    n   -   -   pipe
 flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${recipient}
# ...

main.cf

Code: [Select]
# ...
virtual_transport=dovecot
dovecot_destination_recipient_limit=1
# ...

MailScanner

MailScanner.conf

Code: [Select]
# ...
%org-name% = MYORG
Required SpamAssassin Score = 5
High SpamAssassin Score = 10
Spam Score = yes
Spam Actions = deliver header "X-MYORG-Spam-Flag: Yes"
High Scoring Spam Actions = delete
# ...

Dovecot

Code: [Select]
# ...
protocol lda {
 mail_plugins = cmusieve
 global_script_path = /var/spool/vmail/globalsieverc
 log_path = /var/log/dovecot/deliver.log
 info_log_path = /var/log/dovecot/deliver.log
 # ...
}
auth default {
 socket listen {
   master {
    path = /var/run/dovecot/auth-master
    mode = 0660
    user = vmail
    group = vmail
 }
 # ...
}
# ...

/var/spool/vmail/globalsieverc

Code: [Select]
require ["fileinto"];

# ...

#
# Move SPAM to Junk
#

if anyof (
    header :contains ["X-MYORG-MailScanner-SpamScore"] "sssss",
    header :contains ["X-MYORG-Spam-Flag"] "Yes"
) {
    fileinto "Junk"; stop;
}

Don't forget to doublecheck right permissions to all config files and directories.
SCUBA LIBRE :D

Offline Eleventeen

  • Newbie
  • *
  • Posts: 5
Re: Filtering Spam to "Junk" Folder?
« Reply #2 on: September 28, 2007, 10:51:59 PM »
Wow, thanks for that! I knew it must be possible, but I haven't had much experience with webmail clients since using Squirelmail a few years ago and always found Thunderbird's filtering to work fine so I never gave any thought to serverside filtering. :P

The problem is that I'm running cPanel, with courier-imap and exim. They don't support Dovecot *yet* (although I've read some great things about it, and would switch in a second if they started supporting it. Is it at all possible to filter email using those servers?

thanks again for your help! :)

Offline timelord

  • Jr. Member
  • **
  • Posts: 15
Re: Filtering Spam to "Junk" Folder?
« Reply #3 on: September 29, 2007, 03:09:47 AM »
Sure, as I know, exim has a sieve plugin, so what you need is just set up filter rules for exim's sieve.
SCUBA LIBRE :D

Offline Eleventeen

  • Newbie
  • *
  • Posts: 5
Re: Filtering Spam to "Junk" Folder?
« Reply #4 on: September 30, 2007, 07:40:38 PM »
Odd, I added a .forward file to my home directory and added the rules you suggested, exim doesn't seem to be picking them up. Do I need to install something to use sieve, or do I need to change anything in exim to make it detect .forward files? Thanks again!

Offline timelord

  • Jr. Member
  • **
  • Posts: 15
Re: Filtering Spam to "Junk" Folder?
« Reply #5 on: September 30, 2007, 08:02:21 PM »
I'm sorry, I haven't too much knowledge about Exim, I prefer Postfix.

But try this: www.exim.org+inurl:exim-html-current&ie=utf-8&oe=utf-8]Sieve site:www.exim.org[/url]. There is some good information that can help.
SCUBA LIBRE :D

Offline Eleventeen

  • Newbie
  • *
  • Posts: 5
Re: Filtering Spam to "Junk" Folder?
« Reply #6 on: October 02, 2007, 08:35:14 PM »
I think it's a cPanel related issue, because of the stock exim configuration they provide... I read through that document three times and even looked for some how-to's on using sieve filters with Exim but had no luck. Odd. It's like exim isn't even looking for the .forward file I'm writing. Hopefully some of the pro's at the cPanel forums can give some info about this. ;)

Thanks a lot for your help! If I ever get this working I'll post back with the solution. :)

Offline Steve Corona

  • Newbie
  • *
  • Posts: 7
Re: Filtering Spam to "Junk" Folder?
« Reply #7 on: October 05, 2007, 02:47:47 PM »
Eleventeen,

I use SpamAssassin to filter my spam. Unfortunately, it only appends *****SPAM***** to the subject and keeps the mail in the inbox. I'm not sure exactly how your setup is but if you can make it add something to the subject I wrote a quick roundcube patch today. Basically, it searches for a string in the subject line and if it's present it automatically moves that mail to the junk folder. Here's a link to the forum post:

http://roundcubeforum.net/forum/index.php?topic=2205.0

And to the page with the patch download:

http://fusionreactions.com/pages/rcmail

Let me know if you need anything specific relating to your setup and maybe I can help you out.

Enjoy,

Steve Corona

Offline mrjaguar

  • Jr. Member
  • **
  • Posts: 16
Re: Filtering Spam to "Junk" Folder?
« Reply #8 on: October 31, 2007, 03:25:21 AM »
Steve,
 many of the installations of SA put
X-Spam-Flag: YES
in the header. if you need some other info, or a place to test, or whatever, let me know.
thanks
pat.