John Robinson wrote:
>
> Now, if the aliases files contain e.g.
> foo: bar
> then at the moment, bar is qualified not as @$domain but as
> @$qualify_domain or @$hostname. This is fine for the system aliases but
> not these virtual aliases. If the data were a single item, I could
> manage to produce a string expansion to add @$domain but as the data may
> be a list, not a single entry, I don't know what to do to get any/all
> unqualified addresses returned by the lookup qualified with $domain.
This is a hack, but you could try something like this:
# in the main config
qualify_recipient=unqualified.$qualify_domain
# in your virtual router, add the virtual domain to the address_data:
virtual_aliases:
driver = redirect
allow_fail
allow_defer
domains = dsearch;/etc/mail/domains
local_part_suffix = +* : -*
local_part_suffix_optional
data = ${lookup{$local_part}\
lsearch*{/etc/mail/domains/$domain/aliases}}
address_data = virtualdomain=$domain $address_data
# in the routers, add:
redirect_qualify_recipient:
driver = redirect
domains = $qualify_recipient
data = ${if extract{virtualdomain}{$address_data}\
{$local_part@$value}{$local_part@$qualify_domain}}
One question: how does extract behave if the key appears twice? Does it
take the first value (which I've assumed here?), the last value (in
which case you should put $address_data at the start, not the end), or
undefined behaviour (in which case you'll have to use a complex $sg to
remove a previous virtualdomain from an earlier expansion, I guess).
- Marc