LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 10-24-2005, 11:26 AM   #1
msound
Member
 
Registered: Jun 2003
Location: SoCal
Distribution: CentOS
Posts: 465

Rep: Reputation: 30
deleting mail with spamassassin


I have a postfix mail server running spam assassin and I'd like spam assassin to automatically delete messages marked as spam. I know this can be done but I don't know if I can do it with spamassassin or if I need to do it with a header check script in postfix.

I already know the risk of deleting messages marked spam. We've been testing it for 4 weeks and havent had any false positives. I know users can setup a mail filter in their email client but we have some users on dial up who get 200 emails a day and theyre tired of waiting for all of the crap to download.

If anyone could tell me how to configure spamassassin or postfix to do this I'd appreciate it.
 
Old 10-27-2005, 01:00 AM   #2
hawarden
Newbie
 
Registered: Feb 2005
Location: Hawaii
Distribution: centos/fedora/redhat/solaris
Posts: 28

Rep: Reputation: 15
We run sendmail, spamassassin, and procmail on our mail server. Spamassassin only tags the email as spam or not. We have the handling of the tagged email done for each user in the .procmailrc file in each home directory. That way each user can decide how they want their spam handled. I'm afraid I don't know about postfix configuration. If I remember correctly, in our setup the user's .forward pipes the mail into procmail. From what I vaguely remember from when I set it up a couple years ago, your postfix fills the same slot as our sendmail, and I think I recall documentation giving instructions for configuring procmail/spamassassin with postfix.

I found this link, hope it helps.
http://traxel.com/doc/spamassassin-setup.html
 
Old 11-03-2005, 10:51 AM   #3
msound
Member
 
Registered: Jun 2003
Location: SoCal
Distribution: CentOS
Posts: 465

Original Poster
Rep: Reputation: 30
Thanks for the reply Hawarden.

Fortunately I was able to figure out a really easy way to the spam using Postfix. I use the Postfix header_checks feature to filter out messages that have been marked as spam by spam assassin. Those messages are redirected to a spam mailbox but I can configure Postfix to discard those messages if I want.

Here's how to configure Postfix to automatically filter messages marked as spam, so the messages never hit the users' mailboxes:

Postfix main.cf file
Code:
header_checks = regexp:/etc/postfix/header_checks
Spam Assassin local.cf file
Code:
required_hits 8
report_safe 0
rewrite_header Subject SETSPAM
bayes_autolearn 1
bayes_auto_learn_threshold_nonspam 1
bayes_auto_learn_threshold_spam 5
whitelist_form	*@mydomain.com
Postfix header_checks file
Code:
header_checks
/^Subject: SETSPAM/		REDIRECT spam@mydomain.com
Restart Postfix and you're all set. If I wanted to simply discard all messages marked as spam, I could change my header_checks file to:
Code:
header_checks
/^Subject: SETSPAM/		DISCARD
Pretty cool huh?
 
Old 09-11-2014, 12:25 AM   #4
Klaipedaville
Member
 
Registered: Mar 2013
Posts: 110

Rep: Reputation: Disabled
****Please, disregard information below. It is incorrect.****

I understand this post is very old but I would like to comment on it.

That's a great example actually with its tiny little trick! It took me quite some time to figure it out where the point was.

The matter is that when you change your subject in spamassassin like this:

Code:
 rewrite_header Subject *****SPAM*****
regexp treats ***** as one word (character) SPAM as the second word (character) and ***** again as the third word (character). Therefore you can use it to your advantage. The last commenter changed it to one word of his own at all like this:

Code:
/^Subject: SETSPAM/
and it worked OK. Now if you keep the original that is *****SPAM***** and create your rule like this
Code:
 /^Subject: *****/
it will also do a perfect job and work as good.

Last edited by Klaipedaville; 09-13-2014 at 05:17 AM. Reason: incorrect info
 
Old 09-13-2014, 05:15 AM   #5
Klaipedaville
Member
 
Registered: Mar 2013
Posts: 110

Rep: Reputation: Disabled
Please, disregard my last post. Sorry. It is not right at all. It will block every incoming / outgoing email.

This one is all wrong:

Code:
/^Subject: *****/
The correct regexps to block SPAM are:

Code:
/^Subject: .*\*\*\*\*\*SPAM\*\*\*\*\*/
or

Code:
/^Subject:.*\*{5}SPAM\*{5}/
The number of asterisks in front of and after the word SPAM should match the number you put in your rewrite_header Subject *****SPAM*****.
It has 5 asterisks in my case therefore I put 5 or \*\*\*\*\*
The first .* matches any number of any special characters, it makes the rule harder and helps it match / catch more spam.
 
  


Reply



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
Evolution not deleting POP3 server mail when Getting mail. dummy.1 Linux - Newbie 3 07-13-2004 07:50 AM
Exists a mail-client for Fedora, that can read local mail file without deleting? mxn Linux - Software 1 07-10-2004 12:53 PM
Mail Server and SpamAssassin rurbaniak Linux - Networking 1 03-04-2004 12:14 PM
perl-Mail-SpamAssassin ziggie216 Linux - Software 0 01-05-2004 02:10 PM
Rejecting Mail using Spamassassin and Sendmail granatica Linux - Software 1 07-09-2003 07:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:49 AM.

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