示例#1
0
        public void TestMultipleDomains()
        {
            hMailServer.Domains domains = SingletonProvider <Utilities> .Instance.GetApp().Domains;

            hMailServer.Account account1 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            hMailServer.Account account2 = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            hMailServer.Domain domain2 = SingletonProvider <Utilities> .Instance.AddDomain(domains, "test2.com");

            hMailServer.Account account3 = SingletonProvider <Utilities> .Instance.AddAccount(domain2, "*****@*****.**", "test");

            hMailServer.Account account4 = SingletonProvider <Utilities> .Instance.AddAccount(domain2, "*****@*****.**", "test");

            SMTPClientSimulator smtpSimulator = new SMTPClientSimulator();

            smtpSimulator.Send("*****@*****.**", account1.Address, "Test", "*****@*****.**");
            smtpSimulator.Send("*****@*****.**", account2.Address, "Test", "*****@*****.**");
            smtpSimulator.Send("*****@*****.**", account3.Address, "Test", "*****@*****.**");
            smtpSimulator.Send("*****@*****.**", account4.Address, "Test", "*****@*****.**");

            Assert.IsTrue(POP3Simulator.AssertGetFirstMessageText(account1.Address, "test").Contains(account1.Address));
            Assert.IsTrue(POP3Simulator.AssertGetFirstMessageText(account2.Address, "test").Contains(account2.Address));
            Assert.IsTrue(POP3Simulator.AssertGetFirstMessageText(account3.Address, "test").Contains(account3.Address));
            Assert.IsTrue(POP3Simulator.AssertGetFirstMessageText(account4.Address, "test").Contains(account4.Address));
        }
示例#2
0
        public hMailServer.Domain AddTestDomain()
        {
            ClearDomains();

            hMailServer.Domain domain = AddDomain(application.Domains, "test.com");
            return(domain);
        }
示例#3
0
        private void CreateHMailAccount(hMailServer.Application hApp, string Email, string Password)
        {
            if (IsAuthHMail(hApp))
            {
                hMailServer.Domain domain = hApp.Domains[0];

                hMailServer.Account hAccount;

                string log;

                try {
                    hAccount = domain.Accounts.ItemByAddress[Email];
                    log      = "Изменено:";
                }
                catch (Exception ex) {
                    hAccount = domain.Accounts.Add();
                    log      = "Создано:";
                }

                hAccount.Active   = true;
                hAccount.Address  = Email;
                hAccount.Password = Password;
                hAccount.MaxSize  = Convert.ToInt32(numericUpDown1.Value);

                hAccount.Save();

                log += " " + Email + Environment.NewLine;
                txtLog.AppendText(log);
            }
        }
示例#4
0
        public void TestDomainAdminAccessOtherDomain()
        {
            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            account.AdminLevel = hMailServer.eAdminLevel.hAdminLevelDomainAdmin;
            account.Save();

            SingletonProvider <Utilities> .Instance.AddDomain("example.com");

            hMailServer.Application newApplication = new hMailServer.Application();
            newApplication.Authenticate("*****@*****.**", "test");
            Assert.AreEqual(1, newApplication.Domains.Count);

            hMailServer.Domains domains = SingletonProvider <Utilities> .Instance.GetApp().Domains;

            Assert.AreEqual(2, domains.Count);

            try
            {
                hMailServer.Domain secondDomain = newApplication.Domains.get_ItemByName("example.com");
                Assert.Fail();
            }
            catch (COMException ex)
            {
                Assert.IsTrue(ex.Message.Contains("Invalid index."));
            }
        }
示例#5
0
        protected override void LoadList()
        {
            listAliases.Items.Clear();

            hMailServer.Links  links  = APICreator.Links;
            hMailServer.Domain domain = links.get_Domain(_domainID);
            Marshal.ReleaseComObject(links);

            hMailServer.Aliases aliases = domain.Aliases;
            Marshal.ReleaseComObject(domain);

            for (int i = 0; i < aliases.Count; i++)
            {
                hMailServer.Alias alias = aliases[i];

                ListViewItem item = listAliases.Items.Add(alias.Name);
                item.SubItems.Add(alias.Value);
                item.SubItems.Add(EnumStrings.GetYesNoString(alias.Active));

                item.Tag = alias.ID;

                Marshal.ReleaseComObject(alias);
            }


            Marshal.ReleaseComObject(aliases);
        }
示例#6
0
        public ucDistributionList(int domainID, int listID)
        {
            InitializeComponent();

            _domainID = domainID;

            hMailServer.Links links = APICreator.Links;

            hMailServer.Domain domain = links.get_Domain(_domainID);

            if (listID > 0)
            {
                representedObject = links.get_DistributionList(listID);
                Marshal.ReleaseComObject(links);
            }

            textAddress.Text = "@" + domain.Name;

            Marshal.ReleaseComObject(domain);

            EnableDisable();

            DirtyChecker.SubscribeToChange(this, OnContentChanged);

            new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);
        }
示例#7
0
        protected override void LoadList()
        {
            listDistributionLists.Items.Clear();

            hMailServer.Links             links  = APICreator.Links;
            hMailServer.Domain            domain = links.get_Domain(_domainID);
            hMailServer.DistributionLists lists  = domain.DistributionLists;

            for (int i = 0; i < lists.Count; i++)
            {
                hMailServer.DistributionList list = lists[i];

                ListViewItem item = listDistributionLists.Items.Add(list.Address);

                item.SubItems.Add(EnumStrings.GetYesNoString(list.Active));

                item.Tag = list.ID;

                Marshal.ReleaseComObject(list);
            }

            Marshal.ReleaseComObject(lists);
            Marshal.ReleaseComObject(domain);
            Marshal.ReleaseComObject(links);
        }
示例#8
0
        private void ListUsers()
        {
            EnableDomainsAndList(true);

            if (comboDomains.Items.Count == 0)
            {
                return;
            }

            listItems.Items.Clear();

            int domainID = Convert.ToInt32(comboDomains.SelectedValue);


            hMailServer.Domain   domain   = APICreator.GetDomain(domainID);
            hMailServer.Accounts accounts = domain.Accounts;

            for (int i = 0; i < accounts.Count; i++)
            {
                hMailServer.Account account = accounts[i];

                ListViewItem item = listItems.Items.Add(account.Address);
                item.Tag = account.ID;

                Marshal.ReleaseComObject(account);
            }

            Marshal.ReleaseComObject(accounts);
            Marshal.ReleaseComObject(domain);
        }
示例#9
0
        public ucAccount(int domainID, int accountID)
        {
            InitializeComponent();

            _domainID = domainID;

            hMailServer.Links links = APICreator.Links;

            hMailServer.Domain domain = links.get_Domain(_domainID);

            if (accountID > 0)
            {
                _representedAccount = links.get_Account(accountID);
            }

            textAddress.Text = "@" + domain.Name;

            Marshal.ReleaseComObject(domain);
            Marshal.ReleaseComObject(links);

            comboAdministrationLevel.AddItem(InternalNames.GetAdministrationLevelName(eAdminLevel.hAdminLevelNormal), eAdminLevel.hAdminLevelNormal);
            comboAdministrationLevel.AddItem(InternalNames.GetAdministrationLevelName(eAdminLevel.hAdminLevelDomainAdmin), eAdminLevel.hAdminLevelDomainAdmin);
            comboAdministrationLevel.AddItem(InternalNames.GetAdministrationLevelName(eAdminLevel.hAdminLevelServerAdmin), eAdminLevel.hAdminLevelServerAdmin);
            comboAdministrationLevel.SelectedIndex = 0;

            dateVacationMessageExpiresDate.Value = DateTime.Now;

            DirtyChecker.SubscribeToChange(this, OnContentChanged);
            new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);
        }
示例#10
0
        public void TestSubjectSearchMultipleMatches()
        {
            hMailServer.Domain  oDomain  = _application.Domains[0];
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            // Send a message to this account.
            SMTPClientSimulator oSMTP = new SMTPClientSimulator();

            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
            oSMTP.Send("*****@*****.**", "*****@*****.**", "TestA", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);
            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 3);

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon("*****@*****.**", "test");
            Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

            Assert.AreEqual("1 3", oSimulator.Sort("(SUBJECT) UTF-8 ALL HEADER SUBJECT \"Test1\""));
            Assert.AreEqual("2", oSimulator.Sort("(SUBJECT) UTF-8 ALL HEADER SUBJECT \"TestA\""));
            Assert.AreEqual("3 1", oSimulator.Sort("(REVERSE SUBJECT) UTF-8 ALL HEADER SUBJECT \"Test1\""));
            Assert.AreEqual("2", oSimulator.Sort("(REVERSE SUBJECT) UTF-8 ALL HEADER SUBJECT \"TestA\""));
            Assert.AreEqual("3 1", oSimulator.Sort("(REVERSE SUBJECT) UTF-8 ALL (HEADER SUBJECT) \"Test1\""));
            Assert.AreEqual("2", oSimulator.Sort("(REVERSE SUBJECT) UTF-8 ALL (HEADER SUBJECT) \"TestA\""));
        }
示例#11
0
        public void TestSortReverseSize()
        {
            hMailServer.Domain  oDomain  = _application.Domains[0];
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            StringBuilder longBodyString = new StringBuilder();

            longBodyString.Append('A', 10000);

            // Send a message to this account.
            SMTPClientSimulator oSMTP = new SMTPClientSimulator();

            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", longBodyString.ToString());
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);

            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test2", "Test body");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon("*****@*****.**", "test");
            Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

            Assert.AreEqual("2 1", oSimulator.Sort("(SIZE) UTF-8 ALL"));
            Assert.AreEqual("1 2", oSimulator.Sort("(REVERSE SIZE) UTF-8 ALL"));
        }
示例#12
0
        public void TestSortReverseArrival()
        {
            hMailServer.Domain  oDomain  = _application.Domains[0];
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            // Send a message to this account.
            SMTPClientSimulator oSMTP = new SMTPClientSimulator();

            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test1", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);

            // The two messages needs to be sent a second apart, so we actually need to pause a bit here.

            System.Threading.Thread.Sleep(1000);
            oSMTP.Send("*****@*****.**", "*****@*****.**", "Test2", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

            IMAPSimulator oSimulator = new IMAPSimulator();

            string sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon("*****@*****.**", "test");
            Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

            Assert.AreEqual("1 2", oSimulator.Sort("(ARRIVAL) UTF-8 ALL"));
            Assert.AreEqual("2 1", oSimulator.Sort("(REVERSE ARRIVAL) UTF-8 ALL"));
        }
示例#13
0
        public void TestSortSubjectSearch()
        {
            hMailServer.Domain  oDomain  = _application.Domains[0];
            hMailServer.Account oAccount = SingletonProvider <Utilities> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            // Send a message to this account.
            SMTPClientSimulator oSMTP = new SMTPClientSimulator();

            oSMTP.Send("*****@*****.**", "*****@*****.**", "aa", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 1);
            oSMTP.Send("*****@*****.**", "*****@*****.**", "bb", "This is a test of IMAP Search");
            IMAPSimulator.AssertMessageCount("*****@*****.**", "test", "INBOX", 2);

            IMAPSimulator oSimulator      = new IMAPSimulator();
            string        sWelcomeMessage = oSimulator.Connect();

            oSimulator.Logon("*****@*****.**", "test");
            Assert.IsTrue(oSimulator.SelectFolder("INBOX"));

            Assert.AreEqual("1 2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT aa HEADER SUBJECT bb"));
            Assert.AreEqual("1 2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT aa) (HEADER SUBJECT bb)"));
            Assert.AreEqual("1 2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT aa HEADER SUBJECT bb)"));

            Assert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT aa HEADER SUBJECT cc"));
            Assert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT aa) (HEADER SUBJECT cc)"));
            Assert.AreEqual("1", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT aa HEADER SUBJECT cc)"));

            Assert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR HEADER SUBJECT bb HEADER SUBJECT cc"));
            Assert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED OR (HEADER SUBJECT bb) (HEADER SUBJECT cc)"));
            Assert.AreEqual("2", oSimulator.Sort("(DATE) UTF-8 ALL UNANSWERED (OR HEADER SUBJECT bb HEADER SUBJECT cc)"));
        }
示例#14
0
        public ucAccounts(hMailServer.Domain domain)
        {
            InitializeComponent();

             representedDomain = domain;

             new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);
        }
示例#15
0
        public ucAccounts(hMailServer.Domain domain)
        {
            InitializeComponent();

            representedDomain = domain;

            new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);
        }
示例#16
0
        public hMailServer.Domain AddDomain(hMailServer.Domains oDomains, string sName)
        {
            hMailServer.Domain oDomain = oDomains.Add();
            oDomain.Name   = sName;
            oDomain.Active = true;
            oDomain.Save();

            return(oDomain);
        }
示例#17
0
        public bool SaveData()
        {
            bool newObject = false;

            if (representedObject == null)
            {
                hMailServer.Domain domain = APICreator.GetDomain(_domainID);

                hMailServer.DistributionLists lists = domain.DistributionLists;
                representedObject = lists.Add();
                newObject         = true;

                Marshal.ReleaseComObject(lists);
                Marshal.ReleaseComObject(domain);
            }

            representedObject.Address = textAddress.Text;
            representedObject.Active  = checkEnabled.Checked;

            if (radioModePublic.Checked)
            {
                representedObject.Mode = eDistributionListMode.eLMPublic;
            }

            if (radioModeMembership.Checked)
            {
                representedObject.Mode = eDistributionListMode.eLMMembership;
            }

            if (optModeAnnouncements.Checked)
            {
                representedObject.Mode = eDistributionListMode.eLMAnnouncement;
            }

            representedObject.RequireSenderAddress = textRequireAddress.Text;
            representedObject.RequireSMTPAuth      = checkRequireSMTPAuthentication.Checked;

            representedObject.Save();

            // Refresh the node in the tree if the name has changed.
            IMainForm mainForm = Instances.MainForm;

            mainForm.RefreshCurrentNode(textAddress.Text);

            // Set the object to clean.
            DirtyChecker.SetClean(this);

            if (newObject)
            {
                SearchNodeText crit = new SearchNodeText(representedObject.Address);
                mainForm.SelectNode(crit);
            }

            EnableDisableTabs();

            return(true);
        }
示例#18
0
        public hMailServer.Domain GetDomain()
        {
            hMailServer.Domain domain = null;
            if (_representedObjectID > 0)
            {
                domain = APICreator.GetDomain(_representedObjectID);
            }

            return(domain);
        }
示例#19
0
        public void ClearDomains()
        {
            hMailServer.Domains domains = application.Domains;

            while (domains.Count > 0)
            {
                hMailServer.Domain domain = domains[0];
                domain.Delete();
            }
        }
示例#20
0
        private void SetupDistributionListObject(hMailServer.Domain domain)
        {
            List <string> listRecipients = new List <string>();

            listRecipients.Add("*****@*****.**");
            listRecipients.Add("*****@*****.**");
            listRecipients.Add("*****@*****.**");

            hMailServer.DistributionList list = SingletonProvider <Utilities> .Instance.AddDistributionList(domain, "*****@*****.**", listRecipients);
        }
示例#21
0
        public hMailServer.Alias AddAlias(hMailServer.Domain domain, string sName, string sValue)
        {
            hMailServer.Alias oAlias = domain.Aliases.Add();
            oAlias.Name   = sName;
            oAlias.Value  = sValue;
            oAlias.Active = true;
            oAlias.Save();

            return(oAlias);
        }
示例#22
0
        public static hMailServer.Domain GetDomain(int domainID)
        {
            hMailServer.Links links = APICreator.Application.Links;

            hMailServer.Domain domain = links.get_Domain(domainID);

            Marshal.ReleaseComObject(links);

            return(domain);
        }
示例#23
0
        public void SizeBeforeSend()
        {
            hMailServer.Domain domain = SingletonProvider <Utilities> .Instance.AddTestDomain();

            hMailServer.Account account = SingletonProvider <Utilities> .Instance.AddAccount(domain, "*****@*****.**", "test");

            if (account.Size != 0)
            {
                throw new Exception("Account is not empty");
            }
        }
示例#24
0
        public void SetupEnvironment()
        {
            // Set up the domain. It's already set-up...
            hMailServer.Domain domain = _application.Domains[0];
            Assert.IsNotNull(domain);
            Assert.AreEqual("test.com", domain.Name);

            SetupDomainObject(domain);
            SetupDomainObjects(domain);
            SetupSettings();
        }
示例#25
0
        public hMailServer.Account AddAccount(hMailServer.Domain oDomain, string sAddress, string sPassword, int maxSize)
        {
            hMailServer.Account oAccount = oDomain.Accounts.Add();
            oAccount.Address  = sAddress;
            oAccount.Password = sPassword;
            oAccount.Active   = true;
            oAccount.MaxSize  = maxSize;
            oAccount.Save();


            return(oAccount);
        }
示例#26
0
        internal void OnAddADAccount(object sender, EventArgs e)
        {
            formActiveDirectoryAccounts accountsDlg = new formActiveDirectoryAccounts();

            if (accountsDlg.ShowDialog() == DialogResult.OK)
            {
                hMailServer.Domain   domain   = APICreator.GetDomain(_domainID);
                hMailServer.Accounts accounts = domain.Accounts;

                Instances.MainForm.Cursor = Cursors.WaitCursor;

                string        domainName   = accountsDlg.DomainName;
                List <string> accountNames = accountsDlg.AccountNames;

                foreach (string accountName in accountNames)
                {
                    try
                    {
                        hMailServer.Account account = accounts.Add();

                        account.IsAD       = true;
                        account.ADDomain   = domainName;
                        account.ADUsername = accountName;
                        account.Active     = true;

                        string address = accountName;
                        address         = address.Replace(" ", ".");
                        address         = address + "@" + domain.Name;
                        account.Address = address;

                        account.Save();

                        Marshal.ReleaseComObject(account);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, EnumStrings.hMailServerAdministrator);
                    }
                }

                Marshal.ReleaseComObject(domain);
                Marshal.ReleaseComObject(accounts);

                Instances.MainForm.Cursor = Cursors.Default;
            }

            IMainForm mainForm = Instances.MainForm;

            mainForm.RefreshCurrentNode(null);

            mainForm.ShowItem(mainForm.GetCurrentNode());
        }
示例#27
0
 public static hMailServer.IInterfaceDomain GetDomain(string address)
 {
     string[]           tempaddress = address.Split((new char[] { '@' }));
     hMailServer.Domain domain      = MailApplication.GetEntity().Domains.get_ItemByName(tempaddress[1]);
     if (domain == null)
     {
         throw new MessageException()
               {
                   message = tempaddress[1] + "错误,无此邮箱"
               };
     }
     return(domain);
 }
示例#28
0
        private void ConfirmDomainObject(hMailServer.Domain domain)
        {
            Assert.AreEqual("*****@*****.**", domain.Postmaster);
            Assert.IsTrue(domain.SignatureEnabled);
            Assert.IsTrue(domain.AddSignaturesToLocalMail);
            Assert.IsTrue(domain.AddSignaturesToReplies);
            Assert.AreEqual("PLS", domain.SignaturePlainText);
            Assert.AreEqual("HTML", domain.SignatureHTML);

            Assert.AreEqual("test.com", _application.Domains[0].Name);
            Assert.AreEqual(2, _application.Domains[0].DomainAliases.Count);
            Assert.AreEqual("test1.com", _application.Domains[0].DomainAliases[0].AliasName);
            Assert.AreEqual("test2.com", _application.Domains[0].DomainAliases[1].AliasName);
        }
示例#29
0
        public ucDomain(hMailServer.Domain domain)
        {
            InitializeComponent();

            _domain = domain;

            EnableDisableTabs();

            DirtyChecker.SubscribeToChange(this, OnContentChanged);

            new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);

            EnableDisable();
        }
示例#30
0
        public ucDomain(hMailServer.Domain domain)
        {
            InitializeComponent();

            _domain = domain;

            EnableDisableTabs();

            DirtyChecker.SubscribeToChange(this, OnContentChanged);

            new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);

            EnableDisable();
        }
示例#31
0
        protected override void DeleteItems(List <ListViewItem> items)
        {
            hMailServer.Domains domains = APICreator.Application.Domains;

            foreach (var item in items)
            {
                int domainID = Convert.ToInt32(item.Tag);
                hMailServer.Domain domain = domains.get_ItemByDBID(domainID);
                domain.Delete();
                Marshal.ReleaseComObject(domain);
            }

            Marshal.ReleaseComObject(domains);
        }
示例#32
0
        protected override void DeleteItems(List <ListViewItem> items)
        {
            hMailServer.Domain   domain   = APICreator.GetDomain(_domainID);
            hMailServer.Accounts accounts = domain.Accounts;

            foreach (ListViewItem item in items)
            {
                int accountID = Convert.ToInt32(item.Tag);
                accounts.DeleteByDBID(accountID);
            }

            Marshal.ReleaseComObject(domain);
            Marshal.ReleaseComObject(accounts);
        }
示例#33
0
 public void SetUp()
 {
     _domain = SingletonProvider<Utilities>.Instance.DoBasicSetup();
 }
示例#34
0
 internal Domain(hMailServer.Domain o)
 {
     _object = o;
 }
示例#35
0
        public bool SaveData()
        {
            if (_domain == null)
            {
                hMailServer.Domains domains = _application.Domains;
                _domain = domains.Add();
                Marshal.ReleaseComObject(domains);
            }

            _domain.Name = textDomainName.Text;
            _domain.Postmaster = textCatchAllAddress.Text;
            _domain.AddSignaturesToReplies = checkAddSignaturesToReplies.Checked;
            _domain.AddSignaturesToLocalMail = checkAddSignaturesToLocalMail.Checked;
            _domain.SignatureEnabled = checkSignatureEnabled.Checked;
            _domain.Active = checkEnabled.Checked;

            if (radioSMAppendToAccountSignature.Checked == true)
                _domain.SignatureMethod = eDomainSignatureMethod.eSMAppendToAccountSignature;
            else if (radioSMOverwriteAccountSignature.Checked == true)
                _domain.SignatureMethod = eDomainSignatureMethod.eSMOverwriteAccountSignature;
            else if (radioSMSetIfNotSpecifiedInAccount.Checked == true)
                _domain.SignatureMethod = eDomainSignatureMethod.eSMSetIfNotSpecifiedInAccount;

            _domain.MaxSize = textMaxSize.Number;
            _domain.MaxMessageSize = textMaxMessageSize.Number;
            _domain.MaxAccountSize = textMaxAccountSize.Number;
            _domain.MaxNumberOfAccounts = textMaxNumberOfAccounts.Number;
            _domain.MaxNumberOfAliases = textMaxNumberOfAliases.Number;
            _domain.MaxNumberOfDistributionLists = textMaxNumberOfDistributionLists.Number;

            _domain.MaxNumberOfAccountsEnabled = checkMaxNumberOfAccountsEnabled.Checked;
            _domain.MaxNumberOfAliasesEnabled = checkMaxNumberOfAliasesEnabled.Checked;
            _domain.MaxNumberOfDistributionListsEnabled = checkMaxNumberOfDistributionListsEnabled.Checked;

            _domain.SignaturePlainText = textPlainTextSignature.Text;
            _domain.SignatureHTML = textHTMLSignature.Text;

            _domain.PlusAddressingEnabled = checkUsePlusAddressing.Checked;
            _domain.PlusAddressingCharacter = comboPlusAddressingCharacter.Text;
            _domain.AntiSpamEnableGreylisting = checkGreyListingEnabled.Checked;

            _domain.DKIMSignEnabled = checkDKIMSignEnabled.Checked;
            _domain.DKIMPrivateKeyFile = textDKIMPrivateKeyFile.Text;
            _domain.DKIMSelector = textDKIMSelector.Text;

            if (radioDKIMHeaderMethodSimple.Checked)
                _domain.DKIMHeaderCanonicalizationMethod = eDKIMCanonicalizationMethod.eCanonicalizationSimple;
            else if (radioDKIMHeaderMethodRelaxed.Checked)
                _domain.DKIMHeaderCanonicalizationMethod = eDKIMCanonicalizationMethod.eCanonicalizationRelaxed;

            if (radioDKIMBodyMethodSimple.Checked)
                _domain.DKIMBodyCanonicalizationMethod = eDKIMCanonicalizationMethod.eCanonicalizationSimple;
            else if (radioDKIMBodyMethodRelaxed.Checked)
                _domain.DKIMBodyCanonicalizationMethod = eDKIMCanonicalizationMethod.eCanonicalizationRelaxed;

            if (radioDKIMSigningAlgorithmSHA1.Checked)
                _domain.DKIMSigningAlgorithm = eDKIMAlgorithm.eSHA1;
            else if (radioDKIMSigningAlgorithmSHA256.Checked)
                _domain.DKIMSigningAlgorithm = eDKIMAlgorithm.eSHA256;

            try
            {
                _domain.Save();
            }
            catch (Exception ex)
            {
                MessageBox.Show(Strings.Localize(ex.Message), EnumStrings.hMailServerAdministrator, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            IMainForm mainForm = Instances.MainForm;

            // Refresh the node in the tree
            mainForm.RefreshCurrentNode(_domain.Name);

            // Set the object to clean.
            DirtyChecker.SetClean(this);

            SearchNodeText crit = new SearchNodeText(_domain.Name);
            mainForm.SelectNode(crit);

            EnableDisableTabs();

            return true;
        }