Koozali.org: home of the SME Server

Mail rules - Help!

bearTM

Mail rules - Help!
« Reply #15 on: August 04, 2006, 07:40:42 AM »
Quote from: "renee"
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
Code: [Select]
{
    $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
Code: [Select]
{
    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.

Offline gordonr

  • *
  • 646
  • +0/-0
    • http://www.smeserver.com.au/
Mail rules - Help!
« Reply #16 on: August 04, 2006, 08:45:43 AM »
Quote from: "bearTM"

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.


Great stuff - please raise a New Feature Request in SME Server Future and attach the modified files. Thanks.
............