コード例 #1
0
        public new void SetUp()
        {
            TestSetup.AssertSpamAssassinIsRunning();

            // Enable spam assassin
            application = SingletonProvider <TestSetup> .Instance.GetApp();

            hMailServer.AntiSpam antiSpam = _settings.AntiSpam;

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

            // Disallow incorrect line endings.
            antiSpam.SpamMarkThreshold   = 1;
            antiSpam.SpamDeleteThreshold = 10000;
            antiSpam.AddHeaderReason     = true;
            antiSpam.AddHeaderSpam       = true;
            antiSpam.PrependSubject      = true;
            antiSpam.PrependSubjectText  = "ThisIsSpam";

            // Enable SpamAssassin
            antiSpam.SpamAssassinEnabled    = true;
            antiSpam.SpamAssassinHost       = "localhost";
            antiSpam.SpamAssassinPort       = 783;
            antiSpam.SpamAssassinMergeScore = false;
            antiSpam.SpamAssassinScore      = 5;
        }
コード例 #2
0
        public void ItShouldBePossibleToTestSAConnectionUsingAPIFailure()
        {
            hMailServer.AntiSpam antiSpam = _settings.AntiSpam;

            string resultText;

            CustomAssert.IsFalse(antiSpam.TestSpamAssassinConnection("localhost", 0, out resultText));
        }
コード例 #3
0
        public void ItShouldBePossibleToTestSAConnectionUsingAPISuccess()
        {
            hMailServer.AntiSpam antiSpam = _settings.AntiSpam;

            string resultText;

            CustomAssert.IsTrue(antiSpam.TestSpamAssassinConnection("localhost", 783, out resultText));
            CustomAssert.IsTrue(resultText.Contains("Content analysis details:"));
        }
コード例 #4
0
        public new void SetUp()
        {
            _threadedMessageCount = 0;

            hMailServer.AntiSpam antiSpam = _application.Settings.AntiSpam;

            antiSpam.SpamAssassinEnabled = true;
            antiSpam.SpamAssassinHost    = "127.0.0.1";
            antiSpam.SpamAssassinPort    = 783;

            CustomAsserts.AssertSpamAssassinIsRunning();

            _account = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");
        }
コード例 #5
0
ファイル: Whitelisting.cs プロジェクト: japi/hmailserver
        public new void SetUp()
        {
            _antiSpam = _settings.AntiSpam;

             // We should always mark messages as spam.
             _antiSpam.SpamDeleteThreshold = 5;
             _antiSpam.SpamMarkThreshold = 2;

             _antiSpam.AddHeaderReason = true;
             _antiSpam.AddHeaderSpam = true;
             _antiSpam.PrependSubject = true;
             _antiSpam.PrependSubjectText = "ThisIsSpam";

             SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "*****@*****.**", "test");
        }
コード例 #6
0
ファイル: Combinations.cs プロジェクト: x3650/hmailserver
        public void TestDeleteThresholdLowerThanMarkThreshold()
        {
            Account oAccount1 = SingletonProvider <TestSetup> .Instance.AddAccount(_domain, "*****@*****.**", "test");

            hMailServer.AntiSpam antiSpam = _settings.AntiSpam;

            antiSpam.SpamMarkThreshold   = 15;
            antiSpam.SpamDeleteThreshold = 0;

            antiSpam.AddHeaderReason    = true;
            antiSpam.AddHeaderSpam      = true;
            antiSpam.PrependSubject     = true;
            antiSpam.PrependSubjectText = "ThisIsSpam";

            antiSpam.CheckHostInHelo      = true;
            antiSpam.CheckHostInHeloScore = 10;

            // Enable SURBL.
            SURBLServer oSURBLServer = antiSpam.SURBLServers[0];

            oSURBLServer.Active = true;
            oSURBLServer.Score  = 10;
            oSURBLServer.Save();

            // Send a messages to this account, containing both incorrect MX records an SURBL-hits.
            // We should only detect one of these two:
            var smtpClientSimulator = new SmtpClientSimulator();

            // Should not be possible to send this email since it's results in a spam
            // score over the delete threshold.
            smtpClientSimulator.Send("*****@*****.**", oAccount1.Address, "INBOX",
                                     "Test http://surbl-org-permanent-test-point.com/ Test 2");

            string message = Pop3ClientSimulator.AssertGetFirstMessageText(oAccount1.Address, "test");

            Assert.IsTrue(message.Contains("X-hMailServer-Reason-1:"));
            Assert.IsTrue(message.Contains("X-hMailServer-Reason-2:"));
        }
コード例 #7
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();
        }
コード例 #8
0
ファイル: Basics.cs プロジェクト: jrallo/hMailServer
 public new void SetUp()
 {
     _antiSpam = _settings.AntiSpam;
 }
コード例 #9
0
ファイル: Signing.cs プロジェクト: SpivEgin/hmailserver
        public new void SetUp()
        {
            _antiSpam = _application.Settings.AntiSpam;

             _antiSpam.SpamDeleteThreshold = 5;
        }