Exemple #1
0
        private void ConfirmRoutes()
        {
            hMailServer.Routes routes = _application.Settings.Routes;

            Assert.AreEqual(2, routes.Count);

            hMailServer.Route route = routes[0];
            Assert.AreEqual("test1.com", route.DomainName);
            Assert.AreEqual("description", route.Description);
            Assert.AreEqual(true, route.UseSSL);
            Assert.AreEqual(true, route.TreatSenderAsLocalDomain);
            Assert.AreEqual(false, route.TreatRecipientAsLocalDomain);
            Assert.AreEqual(false, route.TreatSecurityAsLocalDomain);

            route = routes[1];
            Assert.AreEqual("test2.com", route.DomainName);
            Assert.AreEqual("description2", route.Description);
            Assert.AreEqual(false, route.UseSSL);
            Assert.AreEqual(false, route.TreatSenderAsLocalDomain);
            Assert.AreEqual(true, route.TreatRecipientAsLocalDomain);
            Assert.AreEqual(true, route.TreatSecurityAsLocalDomain);

            Assert.AreEqual(2, route.Addresses.Count);

            List <string> addresses = new List <string>();

            addresses.Add(route.Addresses[0].Address);
            addresses.Add(route.Addresses[1].Address);

            Assert.IsTrue(addresses.Contains("*****@*****.**"));
            Assert.IsTrue(addresses.Contains("*****@*****.**"));
        }
Exemple #2
0
        private void SetupRoutes()
        {
            hMailServer.Routes routes = _application.Settings.Routes;

            hMailServer.Route route = routes.Add();
            route.DomainName  = "test1.com";
            route.Description = "description";
            route.UseSSL      = true;
            route.TreatSenderAsLocalDomain    = true;
            route.TreatRecipientAsLocalDomain = false;
            route.Save();

            route             = routes.Add();
            route.DomainName  = "test2.com";
            route.Description = "description2";
            route.UseSSL      = false;
            route.TreatSenderAsLocalDomain    = false;
            route.TreatRecipientAsLocalDomain = true;
            route.Save();

            hMailServer.RouteAddresses addresses = route.Addresses;

            hMailServer.RouteAddress address1 = addresses.Add();
            address1.Address = "*****@*****.**";
            address1.Save();

            hMailServer.RouteAddress address2 = addresses.Add();
            address2.Address = "*****@*****.**";
            address2.Save();
        }
Exemple #3
0
 public void RemoveAllRoutes()
 {
     hMailServer.Routes routes = _settings.Routes;
     while (routes.Count > 0)
     {
         routes[0].Delete();
     }
 }
Exemple #4
0
 public void OnDeleteObject(object sender, EventArgs args)
 {
     if (Utility.AskDeleteItem(_routeName))
     {
         hMailServer.Routes routes = APICreator.Routes;
         routes.DeleteByDBID(_routeID);
         Instances.MainForm.RefreshParentNode();
     }
 }
Exemple #5
0
        protected override void DeleteItems(List <ListViewItem> items)
        {
            hMailServer.Routes routes = APICreator.Routes;

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

            Marshal.ReleaseComObject(routes);
        }
Exemple #6
0
        private void DeleteEnvironment()
        {
            while (_application.Domains.Count > 0)
            {
                _application.Domains[0].Delete();
            }

            hMailServer.WhiteListAddresses addresses = _application.Settings.AntiSpam.WhiteListAddresses;
            while (addresses.Count > 0)
            {
                addresses[0].Delete();
            }

            hMailServer.Routes routes = _application.Settings.Routes;
            while (routes.Count > 0)
            {
                routes[0].Delete();
            }

            hMailServer.BlockedAttachments attachments = _application.Settings.AntiVirus.BlockedAttachments;
            while (attachments.Count > 0)
            {
                attachments[0].Delete();
            }

            hMailServer.DNSBlackLists blackLists = _application.Settings.AntiSpam.DNSBlackLists;
            while (blackLists.Count > 0)
            {
                blackLists[0].Delete();
            }

            hMailServer.SURBLServers surblServers = _application.Settings.AntiSpam.SURBLServers;
            while (surblServers.Count > 0)
            {
                surblServers[0].Delete();
            }

            hMailServer.SSLCertificates sslCertificates = _application.Settings.SSLCertificates;
            while (sslCertificates.Count > 0)
            {
                sslCertificates[0].Delete();
            }

            hMailServer.IncomingRelays incomingRelays = _application.Settings.IncomingRelays;
            while (incomingRelays.Count > 0)
            {
                incomingRelays[0].Delete();
            }
        }
        public void TestDuplicateRoutes()
        {
            hMailServer.Application app = SingletonProvider <Utilities> .Instance.GetApp();

            hMailServer.Routes routes = app.Settings.Routes;

            hMailServer.Route route = routes.Add();
            route.DomainName = "test.com";
            route.Save();

            hMailServer.Route route2 = routes.Add();
            route2.DomainName = "test.com";

            route2.Save();
        }
Exemple #8
0
        public ucRoute(int routeID)
        {
            InitializeComponent();

            if (routeID > 0)
            {
                hMailServer.Routes routes = APICreator.Routes;
                _representedObject = routes.get_ItemByDBID(routeID);
                Marshal.ReleaseComObject(routes);
            }

            DirtyChecker.SubscribeToChange(this, OnContentChanged);

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

            EnableDisable();
        }
Exemple #9
0
        public bool SaveData()
        {
            if (_representedObject == null)
            {
                hMailServer.Settings settings = APICreator.Application.Settings;
                hMailServer.Routes   routes   = settings.Routes;
                _representedObject = routes.Add();

                Marshal.ReleaseComObject(settings);
                Marshal.ReleaseComObject(routes);
            }

            _representedObject.DomainName     = textDomainName.Text;
            _representedObject.Description    = textDescription.Text;
            _representedObject.TargetSMTPHost = textTargetSMTPHost.Text;
            _representedObject.TargetSMTPPort = textTargetSMTPPort.Number;

            _representedObject.ConnectionSecurity = (eConnectionSecurity)comboConnectionSecurity.SelectedValue;

            _representedObject.TreatSenderAsLocalDomain    = radioTreatSenderAsLocalDomain.Checked;
            _representedObject.TreatRecipientAsLocalDomain = radioTreatRecipientAsLocalDomain.Checked;

            _representedObject.NumberOfTries     = textNumberOfTries.Number;
            _representedObject.MinutesBetweenTry = textNumberOfMinutesBetween.Number;

            _representedObject.RelayerRequiresAuth = checkServerRequiresAuth.Checked;
            _representedObject.RelayerAuthUsername = textUsername.Text;


            if (textPassword.Dirty)
            {
                _representedObject.SetRelayerAuthPassword(textPassword.Password);
            }

            _representedObject.AllAddresses = radioRouteForAll.Checked;

            _representedObject.Save();

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

            Utility.RefreshNode(_representedObject.DomainName);

            return(true);
        }
Exemple #10
0
        protected override void LoadList()
        {
            listObjects.Items.Clear();

            hMailServer.Application app      = APICreator.Application;
            hMailServer.Settings    settings = app.Settings;
            hMailServer.Routes      routes   = settings.Routes;
            for (int i = 0; i < routes.Count; i++)
            {
                hMailServer.Route route = routes[i];

                ListViewItem item = listObjects.Items.Add(route.DomainName);
                item.Tag = route.ID;

                Marshal.ReleaseComObject(route);
            }

            Marshal.ReleaseComObject(routes);
            Marshal.ReleaseComObject(settings);
        }
Exemple #11
0
        private void FillCombo()
        {
            comboAction.AddItem(EnumStrings.GetRuleActionString(eRuleActionType.eRADeleteEmail), eRuleActionType.eRADeleteEmail);
            comboAction.AddItem(EnumStrings.GetRuleActionString(eRuleActionType.eRAForwardEmail), eRuleActionType.eRAForwardEmail);
            comboAction.AddItem(EnumStrings.GetRuleActionString(eRuleActionType.eRAMoveToImapFolder), eRuleActionType.eRAMoveToImapFolder);
            comboAction.AddItem(EnumStrings.GetRuleActionString(eRuleActionType.eRAReply), eRuleActionType.eRAReply);
            comboAction.AddItem(EnumStrings.GetRuleActionString(eRuleActionType.eRARunScriptFunction), eRuleActionType.eRARunScriptFunction);
            comboAction.AddItem(EnumStrings.GetRuleActionString(eRuleActionType.eRASetHeaderValue), eRuleActionType.eRASetHeaderValue);
            comboAction.AddItem(EnumStrings.GetRuleActionString(eRuleActionType.eRAStopRuleProcessing), eRuleActionType.eRAStopRuleProcessing);
            comboAction.AddItem(EnumStrings.GetRuleActionString(eRuleActionType.eRACreateCopy), eRuleActionType.eRACreateCopy);


            if (_isAccountLevelRule == false)
            {
                comboAction.AddItem(EnumStrings.GetRuleActionString(eRuleActionType.eRABindToAddress), eRuleActionType.eRABindToAddress);
                comboAction.AddItem(EnumStrings.GetRuleActionString(eRuleActionType.eRASendUsingRoute), eRuleActionType.eRASendUsingRoute);
            }


            comboAction.SelectedIndex = 0;

            // Fill routes
            comboRouteName.AddItem("None", 0);

            hMailServer.Settings settings = APICreator.Application.Settings;
            hMailServer.Routes   routes   = settings.Routes;

            for (int i = 0; i < routes.Count; i++)
            {
                hMailServer.Route route = routes[i];

                comboRouteName.AddItem(route.DomainName, route.ID);

                Marshal.ReleaseComObject(route);
            }
            comboRouteName.SelectedIndex = 0;
            Marshal.ReleaseComObject(routes);
        }