Updating Amavisd configuration for multiple domains

Edit /etc/amavis/conf.d/05-domain_id.

Find the line @local_domains_acl = ( ".$mydomain" ); This needs to be changed to include all of your domains. You can do this manually, e.g. @local_domains_acl = ( "domain1.com", "domain2.com" ); or you can use my handy-dandy Perl script to extract the domains from the mail database and update the file directly.

It might be possible to make Amavisd magically recognize new domains as you add them, but if so, I don't know how. Instead, make this script part of your procedure when adding a new domain through web-cyradm.

Note that if you do not update the Amavis configuration, it isn't a problem. It just means that you won't see your spam detection lines for addresses within that domain. So it would be perfectly okay to run this script some time after adding the domain; possibly as a cron job or whatever.

Use as: update_amavis_domains /etc/amavis/conf.d/05-domain_id. Source for update_amavis_domains: use strict; use DBI; unless (@ARGV == 1) { print "$0 amavis_domain_script\n"; exit 1; } my $db = DBI->connect('DBI:mysql:mail', 'mail', 'shaky+robot:plumy'); my $stmt = $db->prepare( q{   SELECT domain_name from domain } ) or die "Couldn't prepare SELECT: ". $db->errstr; $stmt->execute; my @data; my @domains; while (@data = $stmt->fetchrow_array) { push @domains, "\".$data[0]\""; } $stmt->finish; $db->disconnect; my $filename = $ARGV[0]; my $tmp_filename = $filename. ".tmp"; open(IN, $filename) or die "$filename: $!"; open(OUT, ">$tmp_filename") or die "$tmp_filename: $!"; while () { if (/^\s*\@local_domains_acl/) { # drop all while (!/\)/) {         $_ = ;          unless ($_) {             print "Unexpected EOF or blank line in domain list\n";             print "Please edit by hand before running script\n";             exit 1;          }       }       # now write replacement       print OUT "\@local_domains_acl = (\n   "; print OUT join ",\n  ", @domains; print OUT "\n);\n";   } else {       print OUT;    } } close OUT; close IN; rename $tmp_filename, $filename; print "Don't forget to restart amavisd\n";
 * 1) !/usr/bin/perl -w