# define relay domain
relay_domains = $mydestination  {
    use esmith::DomainsDB;
    my $ddb = esmith::DomainsDB->open_ro;
    my @domains = map { $_->key } $ddb->get_all_by_prop('type' => 'domain');

    $OUT = "\$myhostname \$mydomain $SystemName localhost" if ($DelegateMailServer && ($DelegateMailServer !~ /^\s*$/)) ;

    foreach my $domain ( @domains )
    {
        my $d = $ddb->get($domain);
        $mailserver = $d->prop('MailServer') || $DelegateMailServer || "localhost";
        next if ( $mailserver eq 'localhost');
        $OUT .= "$domain ";
    }
}
