Any way to process lots of messages in webmail with SpamAssassin?

Kent Brockman

Well-Known Member
PartnerNOC
Jan 20, 2008
1,298
68
178
Buenos Aires, Argentina
cPanel Access Level
Root Administrator
Hi! I searched the forums but I had no luck on this one.

I adquired a couple vps where SpamAssassin wasn't auto-deleting spam. So, webmail folders are crowded with spam.

Is there any command line or script to run and make SpamAssassin scan those particular mail accounts to auto-delete its contained spam?

Thanks in advance!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,237
463
Hello :)

It won't scan messages that have already been delivered, but you could develop a bash script that searches for specific content within an email and removes any messages that match the search term.

Thank you.
 

Kent Brockman

Well-Known Member
PartnerNOC
Jan 20, 2008
1,298
68
178
Buenos Aires, Argentina
cPanel Access Level
Root Administrator
ok, that's bad news. well, thanks, I had the hope to automagically been able to run some bash script that make SA scan a delete all those msgs with certain score.

Maybe a find command with awk to detect the string "Score: " and evaluate the value and act accordingly?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,237
463
Maybe a find command with awk to detect the string "Score: " and evaluate the value and act accordingly?
Yes, this is one option that you may find helpful. Note that you likely want to move the messages to another location for a set time period before removing them in-case customers complain of the removal of legitimate email.

Thank you.
 

Kent Brockman

Well-Known Member
PartnerNOC
Jan 20, 2008
1,298
68
178
Buenos Aires, Argentina
cPanel Access Level
Root Administrator
I know, I should try piping results to dir command rather than rm until I got it perfectly ok :) And then, I should move the message files to the spam folder.

I think I need some senior help here. I built the command to read the Scores, but I don't know how to eval them if the value is, let's say, bigger than 5 (for X-Spam-Score: 5 and upper).

Code:
grep -nr "X-Spam-Score: " /home/accountname/mail/[email protected]_com/new | cut -d':' -f4
Not sure how to evaluate values from the command line. Is it possible?