Increase spam assassin score for gmail

Questions and answers about how to do stuff
Post Reply
SelfMan
Posts: 19
Joined: 28 Sep 2021 18:02

Increase spam assassin score for gmail

Post by SelfMan »

Hi guys,
is there a way to increase the spam score of all e-mail received from gmail?
Most of the spam these days comes from the fake/overtaken mailboxes at Gmail.
Sadly, most of them manage to pass through the eFa filters.

Thanks

MailWatch Version: 1.2.18
Operating System Version: CentOS Linux 7 (Core)
Postfix Version: 3.5.9
MailScanner Version: 5.4.2
ClamAV Version: 0.103.5
SpamAssassin Version: 3.4.6
PHP Version: 7.4.27
MySQL Version: 10.2.30-MariaDB
User avatar
shawniverson
Posts: 3607
Joined: 13 Jan 2014 23:30
Location: Indianapolis, Indiana USA
Contact:

Re: Increase spam assassin score for gmail

Post by shawniverson »

Yes.

You could add a custom rule to /etc/mail/spamassassin/local.cf to add a score to anything from gmail.com

https://cwiki.apache.org/confluence/dis ... itingrules
SelfMan
Posts: 19
Joined: 28 Sep 2021 18:02

Re: Increase spam assassin score for gmail

Post by SelfMan »

Thanks!
will try that asap.
SelfMan
Posts: 19
Joined: 28 Sep 2021 18:02

Re: Increase spam assassin score for gmail

Post by SelfMan »

Hi,
I added the custom rules, but they were not applied.
I found out that I have to run sa-update and sa-compile from /etc/mail/spamassassin/ folder.
Is it enough to run this from the GUI console in webmit or does this need to be run as root? (using sudo)

Are a ny other steps required?

Thanks
barbours
Posts: 26
Joined: 24 Sep 2019 06:13

Re: Increase spam assassin score for gmail

Post by barbours »

Please share the custom rule that you used. Has it been successful?
SelfMan
Posts: 19
Joined: 28 Sep 2021 18:02

Re: Increase spam assassin score for gmail

Post by SelfMan »

I added these 2 lines at the end of the /etc/mail/spamassassin/local.cf

Code: Select all

header LOCAL_DEMONSTRATION_FROM	From =~ /\@gmail\.com/i
score LOCAL_DEMONSTRATION_FROM	2.0
It seems to work partially as I don't see the rule being applied every time a mail from gmail.com is received.
User avatar
pdwalker
Posts: 1500
Joined: 18 Mar 2015 09:16

Re: Increase spam assassin score for gmail

Post by pdwalker »

You'll need to post some headers of messages where the rules were not applied.

I added the following rules into /etc/mail/spamassassin/local.cf

Code: Select all

header       ZZ_GMAIL_TEST From =~ /\@gmail\.com/i
score        ZZ_GMAIL_TEST -0.01
describe     ZZ_GMAIL_TEST gmail scoring test using local.cf
I don't know if it matters or not, but I did not use tabs as field separators.

I did not run sa-update and/or sa-compile. In fact these scripts are not in /etc/mail/spamassassin on my installation, but in /usr/bin. I also did not restart any processes.

I then sent an email from my gmail account to the account protected by efa4 and here is what I got:
Screenshot 2022-10-06 at 18.31.png
Screenshot 2022-10-06 at 18.31.png (134.61 KiB) Viewed 409 times
so the rule clearly works.

The missing description is correct as I did not run the "Update SpamAssassin Rule Descriptions" from the "Tools and Links" menu.
SelfMan
Posts: 19
Joined: 28 Sep 2021 18:02

Re: Increase spam assassin score for gmail

Post by SelfMan »

Since I created the rule, there were several updates and restarts of the system. Never the less, I've re-checked all the recent 20 mail from gmail and the rule was applied just fine. I had the problem with the rule not being applied every time only after I created the rule some months ago.
So, from my side the sa-compile mentioned previously helped and everything is fine now.
Post Reply