Topic: BUG Amavis Policy tag, tag2, kill score is 0, clean emails go to SPAM
==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release):
- Deployed with iRedMail Easy or the downloadable installer? downloadable
- Linux/BSD distribution name and version: AlmaLinux9
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): LDAP
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? Yes
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
I think we found a bug when we set up custom SPAM score in iRedAdmin-PRO in System -> Global Spam Policy -> "Mark mail as spam when score is >=" and "Block or quarantine marked spam when score is >=".
When set, the email with score above 0 are tagged as SPAM, but if they are bellow 0, they arrive clean.
In logs we see this:
X-Spam-Status: Yes, score=0.43 tag=0 tag2=0 kill=0
We tested in clean iRedMail, iRedAdmin-Pro, not setting custom SPAM score, everything work ok, the log is:
"tag=2, tag2=6.2, kill=6.9"
If we set custom SPAM score the logs are like in our production:
tag=0 tag2=0 kill=0
If we debug amavis, it gets wrong values from MySQL:
Mar 16 03:10:46 mail amavis[14301]: (14301-01) lookup_sql(user@domain.si) matches, result=(id=>"1", priority=>"0", policy_id=>"5", email=>"@.", fullname=>-, id=>"1", policy_name=>"@.", ..., spam_tag_level=>"0", spam_tag2_level=>"0", spam_tag3_level=>"0", spam_kill_level=>"0", ...
Also here:
Mar 16 03:10:50 mail amavis[14301]: (14301-01) lookup_sql_field(spam_tag_level) rec=0, "user@domain.si" result: "0"
Mar 16 03:10:50 mail amavis[14301]: (14301-01) lookup [spam_tag_level] => false, "user@domain.si" matches, result="0", matching_key="/cached/"
Mar 16 03:10:50 mail amavis[14301]: (14301-01) lookup_sql_field(spam_tag2_level) rec=0, "user@domain.si" result: "0"
Mar 16 03:10:50 mail amavis[14301]: (14301-01) lookup [spam_tag2_level] => false, "user@domain.si" matches, result="0", matching_key="/cached/"
Mar 16 03:10:50 mail amavis[14301]: (14301-01) lookup_sql_field(spam_kill_level) rec=0, "user@domain.si" result: "0"
If we check the official policy table, and compare with iRedMail, they are the same:
https://www.ijs.si/software/amavisd/README.sql-mysql.txt
https://github.com/iredmail/iRedMail/blob/master/samples/amavisd/amavisd.mysql
SQL query from amavisd debug:
Mar 16 03:10:46 mail amavis[14301]: (14301-01) query_keys: user@domain.si, user, @domain.si, @.domain.si, @.si, @.
Mar 16 03:10:46 mail amavis[14301]: (14301-01) lookup_sql sel_policy "user@domain.si", query args: [user@domain.si,-3], [user,-3], [@domain.si,-3], [@.domain.si,-3], [@.si,-3], [@.,-3]
Mar 16 03:10:46 mail amavis[14301]: (14301-01) lookup_sql select: SELECT users.*, policy.*, users.id FROM users LEFT JOIN policy ON users.policy_id=policy.id WHERE users.email IN (?,?,?,?,?,?) ORDER BY users.priority DESC
Mar 16 03:10:46 mail amavis[14301]: (14301-01) sql: preparing and executing (6 args): SELECT users.*, policy.*, users.id FROM users LEFT JOIN policy ON users.policy_id=policy.id WHERE users.email IN (?,?,?,?,?,?) ORDER BY users.priority DESC
So this must me a bug somewhere. I don't know how to diagnose this further. I don't find MySQL select queries for policy in any file.
EDIT: Maybe this is related: https://forum.iredmail.org/post88351.html#p88351
Help would be very appreciated.
Thank you!
----
Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.