Example #1
0
        public void TestDNSBlackList()
        {
            DNSBlackLists dnsBlackLists = SingletonProvider <TestSetup> .Instance.GetApp().Settings.AntiSpam.DNSBlackLists;

            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();

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

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

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

            TestSetup.DeleteCurrentDefaultLog();

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

            string result = TestSetup.ReadCurrentDefaultLog();

            CustomAssert.IsTrue(result.Contains(".zen.spamhaus.org, 0 addresses found: (none), Match: False"), result);
            CustomAssert.IsTrue(result.Contains(".dnsbl.njabl.org, 0 addresses found: (none), Match: False"), result);
            CustomAssert.IsFalse(result.Contains(".bl.spamcop.net, 0 addresses found:"), result);
        }
Example #2
0
        private void SetupDNSBlackLists()
        {
            DNSBlackList black = _application.Settings.AntiSpam.DNSBlackLists.Add();

            black.Active         = true;
            black.DNSHost        = "127.0.0.1";
            black.ExpectedResult = "127.5.2.1";
            black.RejectMessage  = "Test";
            black.Score          = 4;
            black.Save();

            black                = _application.Settings.AntiSpam.DNSBlackLists.Add();
            black.Active         = true;
            black.DNSHost        = "127.0.0.2";
            black.ExpectedResult = "127.5.2.2";
            black.RejectMessage  = "Test2";
            black.Score          = 5;
            black.Save();
        }
Example #3
0
        public void TestDNSBlackList()
        {
            Settings oSettings = SingletonProvider <TestSetup> .Instance.GetApp().Settings;

            DNSBlackList dnsBlackList = oSettings.AntiSpam.DNSBlackLists.Add();

            dnsBlackList.DNSHost       = "somehost.com";
            dnsBlackList.RejectMessage = "somerejectmessage";
            dnsBlackList.Score         = 5;

            dnsBlackList.Save();

            if (dnsBlackList.ID == 0)
            {
                throw new Exception("DNS blacklist not saved properly");
            }

            oSettings.AntiSpam.DNSBlackLists.DeleteByDBID(dnsBlackList.ID);
        }
Example #4
0
        public void DisableSpamProtection()
        {
            hMailServer.AntiSpam antiSpam = _settings.AntiSpam;

            if (antiSpam.SpamMarkThreshold != 10000)
            {
                antiSpam.SpamMarkThreshold = 10000;
            }

            if (antiSpam.SpamDeleteThreshold != 10000)
            {
                antiSpam.SpamDeleteThreshold = 10000;
            }

            if (antiSpam.CheckHostInHelo)
            {
                antiSpam.CheckHostInHelo = false;
            }

            if (antiSpam.GreyListingEnabled)
            {
                antiSpam.GreyListingEnabled = false;
            }

            if (antiSpam.BypassGreylistingOnMailFromMX)
            {
                antiSpam.BypassGreylistingOnMailFromMX = false;
            }

            if (antiSpam.SpamAssassinEnabled)
            {
                antiSpam.SpamAssassinEnabled = false;
            }

            if (antiSpam.TarpitCount != 0)
            {
                antiSpam.TarpitCount = 0;
            }

            if (antiSpam.TarpitDelay != 0)
            {
                antiSpam.TarpitDelay = 0;
            }

            if (antiSpam.UseMXChecks)
            {
                antiSpam.UseMXChecks = false;
            }

            if (antiSpam.UseSPF)
            {
                antiSpam.UseSPF = false;
            }

            if (antiSpam.MaximumMessageSize != 1024)
            {
                antiSpam.MaximumMessageSize = 1024;
            }

            if (antiSpam.DKIMVerificationEnabled)
            {
                antiSpam.DKIMVerificationEnabled = false;
            }

            antiSpam.WhiteListAddresses.Clear();

            for (int i = 0; i < antiSpam.DNSBlackLists.Count; i++)
            {
                DNSBlackList list = antiSpam.DNSBlackLists[i];
                if (list.Active)
                {
                    list.Active = false;
                    list.Save();
                }
            }

            DNSBlackLists dnsBlackLists = antiSpam.DNSBlackLists;

            while (dnsBlackLists.Count > 0)
            {
                dnsBlackLists.DeleteByDBID(dnsBlackLists[0].ID);
            }

            SURBLServers surblServers = antiSpam.SURBLServers;

            for (int i = surblServers.Count - 1; i >= 0; i--)
            {
                if (surblServers[i].DNSHost != "multi.surbl.org")
                {
                    surblServers.DeleteByDBID(surblServers[i].ID);
                }
                else
                {
                    surblServers[i].Active = false;
                }
            }

            if (surblServers.Count == 0)
            {
                SURBLServer surblServer = surblServers.Add();
                surblServer.Active        = false;
                surblServer.DNSHost       = "multi.surbl.org";
                surblServer.RejectMessage = "Nope";
                surblServer.Score         = 5;
                surblServer.Save();
            }

            IncomingRelays incomingRelays = _settings.IncomingRelays;

            while (incomingRelays.Count > 0)
            {
                incomingRelays.DeleteByDBID(incomingRelays[0].ID);
            }

            antiSpam.ClearGreyListingTriplets();
        }