Ejemplo n.º 1
0
        public void TestDNSBlackList()
        {
            hMailServer.DNSBlackLists dnsBlackLists = SingletonProvider <Utilities> .Instance.GetApp().Settings.AntiSpam.DNSBlackLists;

            hMailServer.DNSBlackList dnsBlackList = dnsBlackLists.Add();
            dnsBlackList.DNSHost       = "zen.spamhaus.org";
            dnsBlackList.RejectMessage = "srv1";
            dnsBlackList.Score         = 5;
            dnsBlackList.Active        = true;
            dnsBlackList.Save();

            dnsBlackList               = dnsBlackLists.Add();
            dnsBlackList.DNSHost       = "bl.spamcop.net";
            dnsBlackList.RejectMessage = "srv2";
            dnsBlackList.Score         = 5;
            dnsBlackList.Active        = false;
            dnsBlackList.Save();

            dnsBlackList               = dnsBlackLists.Add();
            dnsBlackList.DNSHost       = "dnsbl.njabl.org";
            dnsBlackList.RejectMessage = "srv3";
            dnsBlackList.Score         = 5;
            dnsBlackList.Active        = true;
            dnsBlackList.Save();

            hMailServer.Application application = SingletonProvider <Utilities> .Instance.GetApp();

            _antiSpam.SpamMarkThreshold   = 1;
            _antiSpam.SpamDeleteThreshold = 100;

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

            Utilities.DeleteCurrentDefaultLog();

            SMTPClientSimulator.StaticSend(account.Address, account.Address, "Test", "TestBody");
            POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

            string result = Utilities.ReadCurrentDefaultLog();

            Assert.IsTrue(result.Contains(".zen.spamhaus.org, 0 addresses found: (none), Match: False"), result);
            Assert.IsTrue(result.Contains(".dnsbl.njabl.org, 0 addresses found: (none), Match: False"), result);
            Assert.IsFalse(result.Contains(".bl.spamcop.net, 0 addresses found:"), result);
        }
Ejemplo n.º 2
0
        public bool SaveData()
        {
            bool newObject = false;

            if (_representedObject == null)
            {
                hMailServer.Settings      settings      = APICreator.Application.Settings;
                hMailServer.AntiSpam      antiSpam      = settings.AntiSpam;
                hMailServer.DNSBlackLists dnsBlackLists = antiSpam.DNSBlackLists;

                _representedObject = dnsBlackLists.Add();
                newObject          = true;

                Marshal.ReleaseComObject(settings);
                Marshal.ReleaseComObject(antiSpam);
                Marshal.ReleaseComObject(dnsBlackLists);
            }

            _representedObject.Active = checkEnabled.Checked;

            _representedObject.DNSHost        = textDNSHost.Text;
            _representedObject.ExpectedResult = textExpectedResult.Text;
            _representedObject.RejectMessage  = textRejectionMessage.Text;
            _representedObject.Score          = textSpamScore.Number;

            _representedObject.Save();


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

            mainForm.RefreshCurrentNode(_representedObject.DNSHost);

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

            if (newObject)
            {
                SearchNodeText crit = new SearchNodeText(_representedObject.DNSHost);
                mainForm.SelectNode(crit);
            }

            return(true);
        }