Script to Run sa-learn for All Mail Users


We recently installed a new Virtualmin Pro server and migrated all virtual servers to it.

I spent a fair amount of time tweaking the spam filtering.

I'm considering running sa-learn for all mail users against their current .spam folder contents. Is this a good idea?

I believe this is the basic command I need to run for each user (please correct me if I'm wrong):

su -s /bin/sh -c "sa-learn --spam --no-sync /home/<virtual-server>/homes/<username>/Maildir/.spam/{cur,new}" - <username>

Does Virtualmin have a built-in way to do this?

Or is there a one-liner to do this?

Thanks in advance.




Sure, you could do that - however, I don't think it would provide much benefit as the spam folder contains messages that spamassasin has already classified as spam ... so it would only be learning from itself.


Thanks again,


But due to my customers getting so many spam in their inbox (spammassin seems to be quite bad) then if they drag spam form the inbox into the spam folder, wouldn't sa-learn then learn from the new spam they move into it, so in theory that same or similar spam wont go into the inbox again? Thanks

SpamAssassin has autolearning in place by default, where anything that is "sufficiently spam" will be automatically added to the spam database.

So a good bit of what's in your junk folder already has been added.

You may want to start looking at some things other than SpamAssassin.... for example, are you using greylisting? If not, that can make a pretty big difference.

It also might be worth looking into some RBL's to add to Postfix as well.