Example #1
0
        private void DeleteEnvironment()
        {
            while (_application.Domains.Count > 0)
            {
                _application.Domains[0].Delete();
            }

            WhiteListAddresses addresses = _application.Settings.AntiSpam.WhiteListAddresses;

            while (addresses.Count > 0)
            {
                addresses[0].Delete();
            }

            Routes routes = _application.Settings.Routes;

            while (routes.Count > 0)
            {
                routes[0].Delete();
            }

            BlockedAttachments attachments = _application.Settings.AntiVirus.BlockedAttachments;

            while (attachments.Count > 0)
            {
                attachments[0].Delete();
            }

            DNSBlackLists blackLists = _application.Settings.AntiSpam.DNSBlackLists;

            while (blackLists.Count > 0)
            {
                blackLists[0].Delete();
            }

            SURBLServers surblServers = _application.Settings.AntiSpam.SURBLServers;

            while (surblServers.Count > 0)
            {
                surblServers[0].Delete();
            }

            SSLCertificates sslCertificates = _application.Settings.SSLCertificates;

            while (sslCertificates.Count > 0)
            {
                sslCertificates[0].Delete();
            }

            IncomingRelays incomingRelays = _application.Settings.IncomingRelays;

            while (incomingRelays.Count > 0)
            {
                incomingRelays[0].Delete();
            }
        }
Example #2
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 #3
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();
        }