2. Pseudonym "@domain1.com" -> "User2"
Result: Mail for User1@domain1.com gets delivered to User1
Here's my solution to the problem ... to enhance the functionality of the aliases/pseudonyms to properly decide what to place into the virtualdomains file.
Now if you specify the pseudonym "@domain.com" -> "User2" in the control panel, it will modify the delivery from "alias-localdelivery" to instead be the user in question. Any other pseudonym which has even a single character in front of the "@domain.com" i.e. "x@domain.com" will still properly get expanded to the virtual domain pseudonym only (as before).
This would make virtualization of domains to a specific user simple, and work as expected.
in /etc/e-smith/templates-custom/var/qmail/control/virtualdomains
80localdomains
{
$OUT = '';
use esmith::DomainsDB;
use esmith::AccountsDB;
my $domainsdb = esmith::DomainsDB->open_ro();
my $accountsdb = esmith::AccountsDB->open_ro;
for my $domain ($domainsdb->domains)
{
my $local_handler = "alias-localdelivery";
my $mail_server = $domain->prop('MailServer')
|| $DelegateMailServer
|| 'localhost';
next if ( $mail_server ne 'localhost' );
$domain = $domain->key;
for my $pseudo ($accountsdb->pseudonyms)
{
next unless ($pseudo->key eq "@".$domain);
$local_handler = $pseudo->prop("Account");
last;
}
$OUT .= "$domain:$local_handler\n";
}
}
90pseudonyms
{
my $dms = $DelegateMailServer;
return "# DelegateMailServer is set" if ($dms && ($dms !~ /^\s*$/));
$OUT = "";
use esmith::AccountsDB;
my $adb = esmith::AccountsDB->open_ro or die "Couldn't open AccountsDB";
for my $pseudo ($adb->pseudonyms)
{
next unless ($pseudo->key =~ /^.+@/);
my $account = $pseudo->prop("Account");
$OUT .= $pseudo->key . ":$account\n";
}
}
Hope this helps out others ...
Robert.