http://www.ijs.si/software/amavisd/README.sql.txthttp://www.ijs.si/software/amavisd/README.sql-mysqlThere are two parts to the schema, basically a read only part and a read/write part. For w/b you would only need to configure the read only part. The amavisd-new developer has normalized the w/b table:
- Code: Select all
CREATE TABLE wblist (
rid integer unsigned NOT NULL, -- recipient: users.id
sid integer unsigned NOT NULL, -- sender: mailaddr.id
wb varchar(10) NOT NULL, -- W or Y / B or N / space=neutral / score
PRIMARY KEY (rid,sid)
);
but I don't, and instead use:
- Code: Select all
CREATE TABLE wblist (
rid integer unsigned NOT NULL, -- recipient: users.id
sid integer unsigned NOT NULL, -- sender: mailaddr.id
priority integer NOT NULL DEFAULT '7',
email varbinary(255) NOT NULL default '',
wb varchar(10) NOT NULL, -- W or Y / B or N / space=neutral / score
PRIMARY KEY (rid,email) -- amavisnewsql specific, normally it's (rid,sid)
);
with this change in amavisd.conf:
- Code: Select all
$sql_select_white_black_list = 'SELECT wb FROM wblist'.
' WHERE (rid=?) AND (wblist.email IN (%k))'.
' ORDER BY wblist.priority DESC';
whereas the amavisd-new developer would have used:
- Code: Select all
# $sql_select_white_black_list = 'SELECT wb FROM wblist,mailaddr'.
# ' WHERE (wblist.rid=?) AND (wblist.sid=mailaddr.id)'.
# ' AND (mailaddr.email IN (%k))'.
# ' ORDER BY mailaddr.priority DESC';
You need to have some understanding that each user is assigned a policy, so at least one policy needs to be created. If you don't want entries in the policy table to affect your current static settings, then setting particular fields to NULL will allow the query to "drop down through" to the static settings. See README.lookups (notably SQL LOOKUPS)
http://www.ijs.si/software/amavisd/#doc and you will discover that amavisd-new queries the SQL table before it queries static entries and "first match wins". It's also important to understand how users.priority affects the query. This is the default select clause:
# $sql_select_policy = 'SELECT *,users.id FROM users,policy'.
# ' WHERE (users.policy_id=policy.id) AND (users.email IN (%k))'.
# ' ORDER BY users.priority DESC';
Read my brief explanation of Amavisd-new lookups
http://www200.pair.com/mecham/spam/virtual2p2.html