This section explains how to setup amavisd-new to make a sql lookup for local domains.
First you'll also need to tell amavis how to access the database and that it should not do whitelist or blacklist lookups:
(replace 'mail-amavis' and 'topsecret' with your database user and password)
@lookup_sql_dsn = ( ['DBI:mysql:database=mail;host=127.0.0.1;port=3306', 'mail-amavis', 'topsecret'], ); $sql_select_white_black_list = undef;
Then set the $sql_select_policy in your amavis config:
$sql_select_policy = 'SELECT "Y" as local, 1 as id FROM domain WHERE CONCAT("@",domain) IN (%k)';
The only "problem" is that it can't use any index because it is expanded to something like
SELECT "Y" as local, 1 as id FROM domain WHERE CONCAT("@",domain) IN ('foo@example.com','@example.com','@.example.com','@.com','@.');
In practise this is not a real problem because the domain table isn't too big, which means lookups without using an index are still fast.
Note: this is not local_domain_maps, but it also works ;-) and even has the advantage that you don't need to restart amavis after adding a domain.