Пример #1
0
 // Delete account mailbox
 private static bool AccountDelete(string userName, string password, string domainName, string accountAddress)
 {
     hMailServer.Application hMailApp = Authenticate(userName, password);
     hMailServer.Domain      myDomain = hMailApp.Domains.ItemByName[domainName];
     hMailServer.Account     account  = myDomain.Accounts.ItemByAddress[accountAddress];
     myDomain.Accounts.DeleteByDBID(account.ID);
     return(true);
 }
Пример #2
0
 // Domain activation or deactivation
 private static bool DomainActivate(string userName, string password, string domainName, bool active = true)
 {
     hMailServer.Application hMailApp = Authenticate(userName, password);
     hMailServer.Domain      myDomain = hMailApp.Domains.ItemByName[domainName];
     myDomain.Active = active;
     myDomain.Save();
     return(true);
 }
Пример #3
0
 // Domain set catchall mailbox
 private static bool DomainActivateCatchAll(string userName, string password, string domainName, string mailboxEmail = "catchall", bool active = true)
 {
     hMailServer.Application hMailApp = Authenticate(userName, password);
     hMailServer.Domain      myDomain = hMailApp.Domains.ItemByName[domainName];
     myDomain.Active     = active;
     myDomain.Postmaster = mailboxEmail + "@" + domainName;
     myDomain.Save();
     return(true);
 }
Пример #4
0
 // Change Account mailbox password
 private static bool ChangAccountPassword(string userName, string password, string domainName, string accountAddress, string newPassword)
 {
     hMailServer.Application hMailApp = Authenticate(userName, password);
     hMailServer.Domain      myDomain = hMailApp.Domains.ItemByName[domainName];
     hMailServer.Account     account  = myDomain.Accounts.ItemByAddress[accountAddress];
     account.Password = newPassword;
     myDomain.Save();
     return(true);
 }
Пример #5
0
 // Deactivate account
 private static bool AccountActivate(string userName, string password, string domainName, string accountAddress, bool active = true)
 {
     hMailServer.Application hMailApp = Authenticate(userName, password);
     hMailServer.Domain      myDomain = hMailApp.Domains.ItemByName[domainName];
     hMailServer.Account     account  = myDomain.Accounts.ItemByAddress[accountAddress];
     account.Active = active;
     account.Save();
     return(true);
 }
Пример #6
0
 // Create new domain
 private static bool DomainCreate(string user, string pass, string domainName)
 {
     hMailServer.Application hMailApp = Authenticate(user, pass);
     hMailServer.Domain      domain   = hMailApp.Domains.Add();
     domain.Name       = domainName;
     domain.Postmaster = "catchall@" + domainName; // add catch all address, mailbox
     domain.Active     = true;
     domain.Save();
     return(true);
 }
Пример #7
0
        // Delete all accounts from domain
        private static bool DeleteAllAccounts(string userName, string password, string domainName)
        {
            hMailServer.Application hMailApp  = Authenticate(userName, password);
            hMailServer.Domain      myDomain  = hMailApp.Domains.ItemByName[domainName];
            hMailServer.Accounts    hAccounts = myDomain.Accounts;

            for (var account = 0; account < hAccounts.Count; account++)
            {
                var accountInfo = hAccounts.get_ItemByDBID(account);
                myDomain.Accounts.DeleteByDBID(accountInfo.ID);
            }
            return(true);
        }
Пример #8
0
 // Create mailbox, Account: [email protected]
 private static bool AccountCreate(string userName, string password, string domainName, string accountAddress, string accountPassword, bool accountActive = true, int maxSize = 1000)
 {
     hMailServer.Application hMailApp = Authenticate(userName, password);
     hMailServer.Domain      myDomain = hMailApp.Domains.ItemByName[domainName];
     if (myDomain != null)
     {
         hMailServer.Account account = myDomain.Accounts.Add();
         account.Address  = accountAddress;
         account.Password = accountPassword;
         account.Active   = accountActive;
         account.MaxSize  = maxSize;
         account.Active   = true;
         account.Save();
         return(true);
     }
     else
     {
         return(false);
     }
 }