[CentOS] Spamassassin + Postfix : delete spam mail on the server ?

Tue Dec 18 13:05:50 UTC 2018
Robert Heller <heller at deepsoft.com>

At Tue, 18 Dec 2018 08:08:55 +0100 CentOS mailing list <centos at centos.org> wrote:

> Hi,
> My mail server is running on CentOS 7 with Postfix, Dovecot and
> Spamassassin. I get quite a lot of spam on a few accounts, and
> Spamassassin does its job fine. Spam mail is identified correctly, and
> it looks like there are no false positives, e. g. valid mail is never
> identified as spam.
> When a message is flagged as spam, the subject line is rewritten to
> begin with [SPAM]. Then, a filter in Mozilla Thunderbird is setup, and
> when a subject line begins with [SPAM] the message is directly sent to
> Trash.

You have two options:

If you have mimedefang installed and using it run spamassassin over all 
incoming messages, you can change mimedefang's default spamassassin filter 
interface from merely tagging messages to actually rejecting them -- 
mimedefang can return a code to tell Postfix to boot the spam message with a 
5xx status. 

Or you can have a recipe in .procmailrc to file (or otherwise) messages tagged 
as spam.

(Another thing you can do is configure Postfix's access and client.cidr files
to refuse to even talk to various hosts that are known spam sources -- pretty
much all of China, Vietnam, Russia (and former USSR countries), and Brazil as
well as all of the "silly" TLDs: .science, .stream, .store, .webcam, 
.acountant, .life, .today, and many more.)

> I've documented the whole configuration here:
>   * https://blog.microlinux.fr/spamassassin-centos/
> The problem with this setup is that spam mail is still delivered, and I
> need Thunderbird's filters to weed out incoming mail. And when I'm using
> my webmail (running SquirrelMail), my inbox is a tsunami of unread
> [SPAM] messages.
> So I'd like to go a step further and delete all messages flagged [SPAM]
> directly on the server. It doesn't look like Spamassassin provides this
> functionality.
> Did any of you guys succeed in doing this anyway?
> Cheers,
> Niki

Robert Heller             -- 978-544-6933
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
heller at deepsoft.com       -- Webhosting Services