Spamassassin + Postfix : Delete Spam Mail On The Server ?
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.
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
—
Microlinux – Solutions informatiques durables
7, place de l’église – 30730 Montpezat Site : https://www.microlinux.fr Blog : https://blog.microlinux.fr Mail : info@microlinux.fr Tél. : 04 66 63 10 32
12 thoughts on - Spamassassin + Postfix : Delete Spam Mail On The Server ?
I’ve used for quite some time now a combination of postfix+SA+MailScanner for this, not delivering mails, but letting those in a quarantine, and using Mailwatch (http frontend) to let people release mail from the quarantine, etc ..
https://www.mailscanner.info/
https://mailwatch.org/
And the ansible role that I initially used for this on CentOS 7 :
https://github.com/arrfab/ansible-role-mail-gateway
Cheers,
Spamassassin just tags things, it doesn’t interact with the final mail delivery. What you need is some form of server-side filtering
My (limited) expertise in MTAs is with Exim and that has an extensive filter syntax that goes in the user’s .forward file – I use that to pre-filter my mail before the MUA sees it. From my .forward file:
if
$h_X-Spam-Flag: contains “Yes”
then
save Maildir/.spam/
finish
endif
if $header_subject: contains “[CentOS” then
save Maildir/.CentOS/
finish
endif
If you don’t want to use a different MTA, then the classic way of doing server side filtering is using procmail. I’m certain there will be lots of HowTos out there on how to set it all up with Postfix.
Finally, I would be quite surprised if there is no built-in filtering of some form with Postfix, but from the articles I’ve just been looking at it doesn’t seem to be a simple process.
P.
Hi,
Procmail, it can move messages around based on many rules. Use something like this in postfix main.cf:
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
And something like this in /etc/procmailrc or $HOME/.procmailrc
SPAMDIR=$HOME/Maildir/.Spam/
:0fw
| /usr/bin/spamc
:0
* ^X-Spam-Status: Yes
$SPAMDIR
DEFAULT=$HOME/Maildir/
ORGMAIL=$HOME/Maildir/
DROPPRIVS=yes
HTH
—
Sent from the Delta quadrant using Borg technology!
Nux!
http://www.nux.ro
—– Original Message —–
At Tue, 18 Dec 2018 08:08:55 +0100 CentOS mailing list wrote:
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
I am just curios how much do they pay you for advertising them in all your posts to this mail list. Or what is different – non-monetary –
incentive you have for doing so?
Valeri
Thanks, Fabian. I was looking for something like that for long time. I
was using the above under amavisd-new. And as I didn’t find GUI
front-end ;-( I ended up using maia mailguard. By that point I switched servers to FreeBSD, and there is FreeBSD maia port which is being actively maintained by brilliant person, so that may be the best source to get maia from, not the main maia website.
Thanks again, it looks like mailwatch does everything I needed (and found in maia): per user white/blacklists, other individual setting, quarantene release, etc.
Valeri
Valeri Galtsev wrote:
Who, Paramount? That’s who owns Trek….
mark “beam me up, Scotty, there’s *no* intelligent life here”
Another alternative that does not alter the original configuration is to use the dovecot sieve plugin. It can manage both global and per user filters, so you can provide a global filter that discards – or, better, move into a dedicated folder – all the messages marked as spam. References:
https://wiki1.dovecot.org/LDA/Sieve <https://wiki1.dovecot.org/LDA/Sieve>
https://wiki2.dovecot.org/Pigeonhole
Best, Andrea
Am 18.12.2018 um 08:08 schrieb Nicolas Kovacs:
What’s the point of delivering identified SPAM and then deleting it?
Reject SPAM at SMTP level on your MTA. Easy to do with amavisd-new in a smtp proxy setup with Postfix.
Alexander
There are good reasons to not reject detected SPAM because your SPAM
filter could be wrong and you reject legitimate mail.
For businesses depending on email communication that’s a no go, because you may lose customers that way.
Regards, Simon
Absolutely, never reject spam at MTA level!
Usually I put it in a spam folder, then add a cronjob that deletes messages older than 6 months, ymmv.
Am 19.12.2018 um 14:49 schrieb Nux!:
Sorry, I see it totally different. But do what you like to do as your own postmaster. There are good reasons to reject SPAM messages instead of initially accepting them.
Alexander