SpamAssassin

From Indie IT Wiki
Revision as of 13:55, 14 May 2021 by imported>Plittlefield (→‎Fix ERROR: URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Fix ERROR: URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked

SpamAssassin will perform many DNS lookups for NetworkTests to significantly improve scoring of messages primarily by DNSBlocklists like Spamhaus, SORBS, etc. This information needs to be cached locally to improve performance and limit the number of external DNS queries since some DNSBlockLists have limits on free usage.

Installing

Install the BIND9 DNS server...

sudo apt-get -y install bind9

Edit the SpamAssassin config file to use the local DNS server...

sudo nano /etc/spamassassin/local.cf
dns_server 127.0.0.1

Restart both daemons...

sudo service bind9 restart
sudo service spamassassin restart

Testing

Use dig to test DNS queries. If you don't get a response then the local DNS server could:

not have proper connectivity outbound to the Internet - a firewall could be blocking UDP/TCP 53 have reached the free usage limit of the DNSBlockList - remove the "+short" to see more detail in the ANSWER section may not be configured correctly - search for articles on how to setup your specific DNS caching server on your specific OS

Spamhaus Zen...

dig +short 2.0.0.127.zen.spamhaus.org

127.0.0.10
127.0.0.4
127.0.0.2

SORBS DUL...

dig 2.0.0.127.dul.dnsbl.sorbs.net +short

127.0.0.10

URIBL...

dig test.uribl.com.multi.uribl.com txt +short

"permanent testpoint"

https://cwiki.apache.org/confluence/display/SPAMASSASSIN/CachingNameserver

Fix Error: util: refusing to untaint suspicious path: "/${SAHOME}"

Edit the /etc/default/spamassassin file and put in the full path instead of a variable SAHOME...

OPTIONS="--create-prefs --max-children 5 --username debian-spamd --helper-home-dir "/var/lib/spamassassin/" -s "/var/lib/spamassassin/spamd.log"

https://tipstricks.itmatrix.eu/fixing-spamassassin-in-debian-jessie8/?cn-reloaded=1

Adjust Rule Scores

nano /etc/mail/spamassassin/local.cf

# score PLING_PLING 1.047 1.325 1.157 0.650
score PLING_PLING 2.1 2.7 2.3 1.3  # Double default scores

https://wiki.apache.org/spamassassin/AdjustRuleScore

Whitelist

sudo nano /etc/spamassassin/local.cf

## WHITELIST whitelist
whitelist_from alright@domain.com

sudo service spamassassin restart

https://wiki.apache.org/spamassassin/ManualWhitelist

Blacklist

sudo nano /etc/spamassassin/local.cf

## BLACKLIST blacklist
blacklist_from @milesandbarr.co.uk
blacklist_from @gabrielle-paris.com

sudo service spamassassin restart

https://wiki.apache.org/spamassassin/ManualBlacklist

Test Different Configuration Settings

Everything...

sudo spamassassin -D --lint

Bayesian Classifier...

sudo spamassassin -D bayes --lint

DCC...

sudo spamassassin -D dcc --lint

Pyzor...

sudo spamassassin -D pyzor --lint

Razor2...

sudo spamassassin -D razor2 --lint

Set: Bayes Files

sudo nano /etc/mail/spamassassin/local.cf

or maybe...

sudo nano /etc/spamassassin/mailscanner.cf
     auto_whitelist_path /var/spool/MailScanner/spamassassin/auto-whitelist
     auto_whitelist_file_mode 0664
     bayes_path /var/spool/MailScanner/spamassassin/bayes
     bayes_file_mode 0664
     use_bayes 1

Change Spam And Learn From A Single Message

sudo sa-learn --forget /home/spam/.maildir/new/1395249824.M568465P26233.mail,S=6623,W=6782
sudo sa-learn --ham /home/spam/.maildir/new/1395249824.M568465P26233.mail,S=6623,W=6782
sudo mv /home/spam/.maildir/new/1395249824.M568465P26233.mail,S=6623,W=6782 /home/user/.maildir/new/

Thanks to Faisal.