I'm tying to setup exim4 as MTA for multidomain host. All users and domains are virtual, stored in the database like that:
create table emails
(
domain varchar(200),
username varchar(200),
password varchar(200)
)
Mesages are stored in the maildirs:
directory = /var/spool/mail/$domain/$local_part
I have multiple domains, like private.tld, company1.tld and company2.tld. I want to setup exim to handle company1 and company2 domains like company1, and want, as well, to handle subdomains, like www.private.tld as private.tld. And I need this to be performed for every user, without explicit aliases for each user. As I understand, I need to make a kind of domain aliases, so I created the table:
create table domains_aliases
(
source_domain varchar(300),
replacement_domain varchar(300)
)
And added
select source_domain from domains_aliases
to the MAIN_LOCAL_DOMAINS.
And now I'd like to write a rule with condition for domains, listed in this table, probably like that (not sure):
condition=${lookup sql{select source_domain from domain_aliases where source_domain=${quote_sql:$domain}}{{yes}{no}}}
And perform replacement then - change $domain to select replacement_domain from domains_aliases where source_domain='${quote_sql:$domain}'
I searched docs but did not find how to make this. Maybe some headers_rewrite? Cannot find this in the documentation, it's a bit unclear for me, please help.
Update: Just realized that it is possible to make driver=redirect for something like select $loacl_part@replacement_domain from domain_aliases where source_domain=$domain
, but maybe there's a better way?