public void TestEnabled()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

            hMailServer.WhiteListAddresses obAddresses = _antiSpam.WhiteListAddresses;
            hMailServer.WhiteListAddress   obAddress   = obAddresses.Add();

            obAddress.EmailAddress   = "*****@*****.**";
            obAddress.LowerIPAddress = "0.0.0.0";
            obAddress.UpperIPAddress = "255.255.255.255";
            obAddress.Description    = "Test";
            obAddress.Save();

            // Enable SURBL.
            hMailServer.SURBLServer oSURBLServer = _antiSpam.SURBLServers[0];
            oSURBLServer.Active = true;
            oSURBLServer.Score  = 5;
            oSURBLServer.Save();

            // Send a messages to this account.
            Assert.IsTrue(SMTPClientSimulator.StaticSend("*****@*****.**", "*****@*****.**", "SURBL-Match", "This is a test message with a SURBL url: -> http://surbl-org-permanent-test-point.com/ <-"));

            obAddresses.DeleteByDBID(obAddress.ID);

            // Check that it's detected as spam again.
            Assert.IsFalse(SMTPClientSimulator.StaticSend("*****@*****.**", "*****@*****.**", "SURBL-Match", "This is a test message with a SURBL url: -> http://surbl-org-permanent-test-point.com/ <-"));

            POP3Simulator.AssertMessageCount("*****@*****.**", "test", 1);
        }
示例#2
0
        private void EditSelectedItem()
        {
            if (listWhiteAddresses.SelectedItems.Count != 1)
            {
                return;
            }

            int id = Convert.ToInt32(listWhiteAddresses.SelectedItems[0].Tag);

            hMailServer.WhiteListAddresses addresses = GetWhiteListAddresses();
            hMailServer.WhiteListAddress   address   = addresses.get_ItemByDBID(id);

            formWhiteListAddress whiteDlg = new formWhiteListAddress();

            whiteDlg.LoadProperties(address);

            if (whiteDlg.ShowDialog() == DialogResult.OK)
            {
                whiteDlg.SaveProperties(address);

                address.Save();

                ListItems();
            }

            Marshal.ReleaseComObject(address);
            Marshal.ReleaseComObject(addresses);
        }
示例#3
0
        private hMailServer.WhiteListAddresses GetWhiteListAddresses()
        {
            hMailServer.AntiSpam           antiSpam  = APICreator.AntiSpamSettings;
            hMailServer.WhiteListAddresses addresses = antiSpam.WhiteListAddresses;

            Marshal.ReleaseComObject(antiSpam);

            return(addresses);
        }
示例#4
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 TestFormatVariations()
        {
            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

            hMailServer.WhiteListAddresses obAddresses = _antiSpam.WhiteListAddresses;

            hMailServer.WhiteListAddress obAddress = obAddresses.Add();

            string address = @"A%B/C\[email protected]";

            obAddress.EmailAddress = address;
            Assert.AreEqual(address, obAddress.EmailAddress);

            address = @"\%%%__\[email protected]";
            obAddress.EmailAddress = address;
            Assert.AreEqual(address, obAddress.EmailAddress);
        }
示例#6
0
        private void ConfirmWhiteList()
        {
            hMailServer.WhiteListAddresses addresses = _application.Settings.AntiSpam.WhiteListAddresses;

            Assert.AreEqual(2, addresses.Count);

            hMailServer.WhiteListAddress address = addresses[0];
            Assert.AreEqual("Desc1", address.Description);
            Assert.AreEqual("Email1", address.EmailAddress);
            Assert.AreEqual("1.1.1.1", address.LowerIPAddress);
            Assert.AreEqual("2.2.2.2", address.UpperIPAddress);

            address = addresses[1];
            Assert.AreEqual("Desc2", address.Description);
            Assert.AreEqual("Email2", address.EmailAddress);
            Assert.AreEqual("2.2.2.2", address.LowerIPAddress);
            Assert.AreEqual("21.21.21.21", address.UpperIPAddress);
        }
示例#7
0
        private void SetupWhiteList()
        {
            hMailServer.WhiteListAddresses addresses = _application.Settings.AntiSpam.WhiteListAddresses;

            hMailServer.WhiteListAddress address = addresses.Add();
            address.Description    = "Desc1";
            address.EmailAddress   = "Email1";
            address.LowerIPAddress = "1.1.1.1";
            address.UpperIPAddress = "2.2.2.2";
            address.Save();

            address                = addresses.Add();
            address.Description    = "Desc2";
            address.EmailAddress   = "Email2";
            address.LowerIPAddress = "2.2.2.2";
            address.UpperIPAddress = "21.21.21.21";
            address.Save();
        }
示例#8
0
        private void buttonDeleteWhiteAddress_Click(object sender, EventArgs e)
        {
            if (!Utility.AskDeleteItems())
            {
                return;
            }

            hMailServer.WhiteListAddresses addresses = GetWhiteListAddresses();

            foreach (ListViewItem item in listWhiteAddresses.SelectedItems)
            {
                int id = Convert.ToInt32(item.Tag);
                addresses.DeleteByDBID(id);
            }

            Marshal.ReleaseComObject(addresses);

            ListItems();
        }
示例#9
0
        private void ListItems()
        {
            listWhiteAddresses.Items.Clear();

            hMailServer.WhiteListAddresses addresses = GetWhiteListAddresses();

            for (int i = 0; i < addresses.Count; i++)
            {
                hMailServer.WhiteListAddress address = addresses[i];

                ListViewItem item = listWhiteAddresses.Items.Add(address.Description);
                item.SubItems.Add(address.LowerIPAddress);
                item.SubItems.Add(address.UpperIPAddress);
                item.SubItems.Add(address.EmailAddress);

                item.Tag = address.ID;
            }

            Marshal.ReleaseComObject(addresses);
        }
示例#10
0
        private void buttonAddWhiteAddress_Click(object sender, EventArgs e)
        {
            formWhiteListAddress whiteDlg = new formWhiteListAddress();

            if (whiteDlg.ShowDialog() == DialogResult.OK)
            {
                hMailServer.AntiSpam           antiSpam  = APICreator.AntiSpamSettings;
                hMailServer.WhiteListAddresses addresses = antiSpam.WhiteListAddresses;
                hMailServer.WhiteListAddress   address   = addresses.Add();

                whiteDlg.SaveProperties(address);

                address.Save();

                Marshal.ReleaseComObject(antiSpam);
                Marshal.ReleaseComObject(addresses);
                Marshal.ReleaseComObject(address);

                ListItems();
            }
        }