当前位置: 首页>>代码示例>>C#>>正文


C# Shared.SMTPClientSimulator类代码示例

本文整理汇总了C#中RegressionTests.Shared.SMTPClientSimulator的典型用法代码示例。如果您正苦于以下问题:C# SMTPClientSimulator类的具体用法?C# SMTPClientSimulator怎么用?C# SMTPClientSimulator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SMTPClientSimulator类属于RegressionTests.Shared命名空间,在下文中一共展示了SMTPClientSimulator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestDistributionListAnnouncementFromDomainAlias

        public void TestDistributionListAnnouncementFromDomainAlias()
        {
            var oIMAP = new IMAPSimulator();
             var oSMTP = new SMTPClientSimulator();

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

             //
             // TEST LIST SECURITY IN COMBINATION WITH DOMAIN NAME ALIASES
             //

             Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             var oRecipients = new List<string>();
             oRecipients.Add("[email protected]");

             DistributionList oList3 = SingletonProvider<TestSetup>.Instance.AddDistributionList(_domain, "[email protected]",
                                                                                             oRecipients);
             oList3.Mode = eDistributionListMode.eLMAnnouncement;
             oList3.RequireSenderAddress = "[email protected]";
             oList3.Save();

             // THIS MESSAGE SHOULD FAIL
             Assert.IsFalse(oSMTP.Send("[email protected]", "[email protected]", "Mail 1", "Mail 1"));

             DomainAlias oDA = _domain.DomainAliases.Add();
             oDA.AliasName = "dummy-example.com";
             oDA.Save();

             // THIS MESSAGE SHOULD SUCCEED
             Assert.IsTrue(oSMTP.Send("[email protected]", "[email protected]", "Mail 1", "Mail 1"));
             IMAPSimulator.AssertMessageCount("[email protected]", "test", "Inbox", 1);
        }
开发者ID:jrallo,项目名称:hMailServer,代码行数:33,代码来源:DistributionLists.cs

示例2: DoNotUseStartTlsIfNotEnabledAndNotAvailable

        public void DoNotUseStartTlsIfNotEnabledAndNotAvailable()
        {
            // No valid recipients...
             var deliveryResults = new Dictionary<string, int>();
             deliveryResults["[email protected]"] = 250;

             int smtpServerPort = TestSetup.GetNextFreePort();
             using (var server = new SMTPServerSimulator(1, smtpServerPort, eConnectionSecurity.eCSNone))
             {
            server.AddRecipientResult(deliveryResults);
            server.StartListen();

            Route route = SMTPClientTests.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSNone);

            // Send message to this route.
            var smtp = new SMTPClientSimulator();
            if (!smtp.Send("[email protected]", "[email protected]", "Test", "Test message"))
               CustomAssert.Fail("Delivery failed");

            // Wait for the client to disconnect.
            server.WaitForCompletion();

            TestSetup.AssertRecipientsInDeliveryQueue(0, false);

            Assert.IsNotNullOrEmpty(server.MessageData);

            CustomAssert.IsFalse(TestSetup.DefaultLogContains("220 Ready to start TLS"));
             }
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:29,代码来源:SMTPClientStartTLSTests.cs

示例3: ConfirmSingleReturnPathAfterAccountForward

        public void ConfirmSingleReturnPathAfterAccountForward()
        {
            // Create a test account
             // Fetch the default domain
             Account oAccount1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
             Account oAccount2 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             oAccount1.ForwardAddress = oAccount2.Address;
             oAccount1.ForwardEnabled = true;
             oAccount1.Save();

             // Send a message...
             var oSMTP = new SMTPClientSimulator();
             oSMTP.Send("[email protected]", oAccount1.Address, "Test message", "This is the body");

             TestSetup.AssertRecipientsInDeliveryQueue(0);
             _application.SubmitEMail();

             // Wait for the auto-reply.
             string text = POP3Simulator.AssertGetFirstMessageText(oAccount2.Address, "test");

             Assert.IsFalse(text.Contains("Return-Path: [email protected]"));
             Assert.IsFalse(text.Contains("Return-Path: [email protected]"));
             Assert.IsTrue(text.Contains("Return-Path: [email protected]"));
        }
开发者ID:jrallo,项目名称:hMailServer,代码行数:25,代码来源:AccountServices.cs

示例4: TestBlockingDeliveries

        public void TestBlockingDeliveries()
        {
            SecurityRange range =
            SingletonProvider<TestSetup>.Instance.GetApp().Settings.SecurityRanges.get_ItemByName("My computer");
             range.RequireSMTPAuthLocalToLocal = false;
             range.RequireSMTPAuthLocalToExternal = false;
             range.RequireSMTPAuthExternalToLocal = false;
             range.RequireSMTPAuthExternalToExternal = false;

             range.AllowDeliveryFromLocalToLocal = false;
             range.AllowDeliveryFromLocalToRemote = false;
             range.AllowDeliveryFromRemoteToLocal = false;
             range.AllowDeliveryFromRemoteToRemote = false;

             range.Save();

             Account account1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             var oSMTP = new SMTPClientSimulator();

             string result1, result2, result3, result4;

             Assert.IsFalse(oSMTP.Send(account1.Address, account1.Address, "Mail 1", "Mail 1", out result1));
             Assert.IsFalse(oSMTP.Send(account1.Address, "[email protected]", "Mail 1", "Mail 1", out result2));
             Assert.IsFalse(oSMTP.Send("[email protected]", account1.Address, "Mail 1", "Mail 1", out result3));
             Assert.IsFalse(oSMTP.Send("[email protected]", "[email protected]", "Mail 1", "Mail 1",
                                   out result4));

             Assert.IsTrue(result1.Contains("550 Delivery is not allowed to this address."));
             Assert.IsTrue(result2.Contains("550 Delivery is not allowed to this address."));
             Assert.IsTrue(result3.Contains("550 Delivery is not allowed to this address."));
             Assert.IsTrue(result4.Contains("550 Delivery is not allowed to this address."));
        }
开发者ID:jrallo,项目名称:hMailServer,代码行数:33,代码来源:SMTPAuthentication.cs

示例5: SmtpServerNOTSupportingStartTls_StartTlsRequired

        public void SmtpServerNOTSupportingStartTls_StartTlsRequired()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             // Set up a server listening on port 250 which accepts email for [email protected]
             var deliveryResults = new Dictionary<string, int>();
             deliveryResults["[email protected]"] = 250;

             int smtpServerPort = TestSetup.GetNextFreePort();
             using (var server = new SMTPServerSimulator(1, smtpServerPort, eConnectionSecurity.eCSNone))
             {
            server.SetCertificate(SslSetup.GetCertificate());
            server.AddRecipientResult(deliveryResults);
            server.StartListen();

            Route route = SMTPClientTests.AddRoutePointingAtLocalhost(1, smtpServerPort, true, eConnectionSecurity.eCSSTARTTLSRequired);

            var smtpClient = new SMTPClientSimulator();
            CustomAssert.IsTrue(smtpClient.Send(account.Address, "[email protected]", "Test", "Test message"));

            TestSetup.AssertRecipientsInDeliveryQueue(0);

            // This should now be processed via the rule -> route -> external server we've set up.
            server.WaitForCompletion();

            var msg = POP3ClientSimulator.AssertGetFirstMessageText("[email protected]", "test");

            CustomAssert.IsTrue(msg.Contains("Server does not support STARTTLS"));
             }
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:30,代码来源:SmtpDeliverySslTests.cs

示例6: TestDomainAliases

        public void TestDomainAliases()
        {
            // Create a test account
             // Fetch the default domain
             DomainAlias oDomainAlias = _domain.DomainAliases.Add();
             oDomainAlias.AliasName = "alias.com";
             oDomainAlias.Save();

             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]",
                                                                             "test");

             // Send 5 messages to this account.
             var oSMTP = new SMTPClientSimulator();
             for (int i = 0; i < 5; i++)
            oSMTP.Send("[email protected]", "[email protected]", "INBOX", "Alias test message");

             POP3Simulator.AssertMessageCount("[email protected]", "test", 5);

             {
            oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain,
                                                                        "domain-alias-test-[email protected]", "test");

            // Set up an alias pointing at the domain alias.
            SingletonProvider<TestSetup>.Instance.AddAlias(_domain, "[email protected]",
                                                           "[email protected]");

            // Send to the alias
            for (int i = 0; i < 5; i++)
               oSMTP.Send(oAccount.Address, "[email protected]", "INBOX", "Plus addressing message");
            // Wait for completion

            POP3Simulator.AssertMessageCount(oAccount.Address, "test", 5);
             }
        }
开发者ID:japi,项目名称:hmailserver,代码行数:34,代码来源:DomainServices.cs

示例7: TestNestedOrSearch

        public void TestNestedOrSearch()
        {
            Application application = SingletonProvider<TestSetup>.Instance.GetApp();

             Account oAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             // Send a message to this account.
             var oSMTP = new SMTPClientSimulator();
             oSMTP.Send("[email protected]", "[email protected]", "Search test", "This is a test of IMAP Search");

             IMAPClientSimulator.AssertMessageCount(oAccount.Address, "test", "Inbox", 1);

             var oSimulator = new IMAPClientSimulator();
             string sWelcomeMessage = oSimulator.Connect();
             oSimulator.Logon("[email protected]", "test");
             oSimulator.SelectFolder("INBOX");

             string result =
            oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SINCE 28-May-2008 SINCE 28-May-2008 SINCE 28-May-2008");
             CustomAssert.IsTrue(result.StartsWith("* SEARCH 1"), result);

             result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR SMALLER 1 LARGER 10000");
             CustomAssert.IsTrue(result.StartsWith("* SEARCH\r\n"), result);

             result = oSimulator.SendSingleCommand("A4 SEARCH ALL OR OR SMALLER 1 LARGER 10000 SMALLER 10000");
             CustomAssert.IsTrue(result.StartsWith("* SEARCH 1\r\n"), result);
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:27,代码来源:Search.cs

示例8: StaticSend

        public static bool StaticSend(string sFrom, string recipient, string sSubject, string sBody)
        {
            var messageRecipients = new List<string>();
             messageRecipients.Add(recipient);

             var oSimulator = new SMTPClientSimulator();
             return oSimulator.Send(sFrom, messageRecipients, sSubject, sBody);
        }
开发者ID:japi,项目名称:hmailserver,代码行数:8,代码来源:SMTPClientSimulator.cs

示例9: TestCaseInsensitivtyAccount

        public void TestCaseInsensitivtyAccount()
        {
            Account testAccount = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");

             var oSMTP = new SMTPClientSimulator();
             string upperCase = testAccount.Address.ToUpper();
             Assert.IsTrue(oSMTP.Send("[email protected]", upperCase, "test mail", "test body"));

             POP3Simulator.AssertMessageCount("[email protected]", "test", 1);
        }
开发者ID:jrallo,项目名称:hMailServer,代码行数:10,代码来源:Basics.cs

示例10: TestESMTPSInHeader

        public void TestESMTPSInHeader()
        {
            var smtpClientSimulator = new SMTPClientSimulator(false, 25002);

             string errorMessage;
             smtpClientSimulator.Send(true, string.Empty, string.Empty, _account.Address, _account.Address, "Test", "test", out errorMessage);

             var message = POP3ClientSimulator.AssertGetFirstMessageText(_account.Address, "test");
             CustomAssert.IsTrue(message.Contains("ESMTPS\r\n"));
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:10,代码来源:ReceivedHeaders.cs

示例11: TestESMTPAInHeader

        public void TestESMTPAInHeader()
        {
            string errorMessage;

             var client = new SMTPClientSimulator();
             client.Send(false, _account.Address, "test", _account.Address, _account.Address, "Test", "Test", out errorMessage);

             var message = POP3ClientSimulator.AssertGetFirstMessageText(_account.Address, "test");

             CustomAssert.IsTrue(message.Contains("ESMTPA\r\n"));
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:11,代码来源:ReceivedHeaders.cs

示例12: TestLongLineInData

        public void TestLongLineInData()
        {
            Account account = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "test");
             var sb = new StringBuilder();
             for (int i = 0; i < 11000; i++)
             {
            sb.Append("1234567890");
             }

             var sim = new SMTPClientSimulator();
             Assert.IsFalse(sim.SendRaw("[email protected]", "[email protected]", sb.ToString()));
        }
开发者ID:jrallo,项目名称:hMailServer,代码行数:12,代码来源:ContentStressTest.cs

示例13: MessageHeaderShouldBeValidAfterSAHasRun

        public void MessageHeaderShouldBeValidAfterSAHasRun()
        {
            // Send a messages to this account.
             var smtpClient = new SMTPClientSimulator();
            smtpClient.Send(account.Address, account.Address, "SA test",
                    "This is a test message with spam.\r\n XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X.");

             string fullMessage = POP3ClientSimulator.AssertGetFirstMessageText(account.Address, "test");

             string messageHeader = fullMessage.Substring(0, fullMessage.IndexOf("\r\n\r\n"));
             CustomAssert.IsTrue(messageHeader.Contains("Received:"));
             CustomAssert.IsTrue(messageHeader.Contains("Return-Path:"));
             CustomAssert.IsTrue(messageHeader.Contains("From:"));
             CustomAssert.IsTrue(messageHeader.Contains("Subject: ThisIsSpam"));
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:15,代码来源:SpamAssassin.cs

示例14: TestEmptyPassword

        public void TestEmptyPassword()
        {
            Account account1 = SingletonProvider<TestSetup>.Instance.AddAccount(_domain, "[email protected]", "");

             string message;
             var sim = new POP3Simulator();
             Assert.IsFalse(sim.ConnectAndLogon(account1.Address, "", out message));

             var simIMAP = new IMAPSimulator();
             Assert.IsFalse(simIMAP.ConnectAndLogon(account1.Address, "", out message));
             Assert.AreEqual("A01 NO Invalid user name or password.\r\n", message);

             var simSMTP = new SMTPClientSimulator();
             Assert.IsFalse(simSMTP.ConnectAndLogon(25, "dGVzdEB0ZXN0LmNvbQ==", "", out message));
             Assert.AreEqual("535 Authentication failed. Restarting authentication process.\r\n", message);
        }
开发者ID:jrallo,项目名称:hMailServer,代码行数:16,代码来源:Basics.cs

示例15: RoutesShouldConsolidateRecipients

        public void RoutesShouldConsolidateRecipients()
        {
            // Set up a server listening on port 250 which accepts email for [email protected]
             var deliveryResults = new Dictionary<string, int>();
             deliveryResults["[email protected]"] = 250;
             deliveryResults["[email protected]"] = 250;
             deliveryResults["[email protected]"] = 250;
             deliveryResults["[email protected]"] = 250;

             int smtpServerPort = TestSetup.GetNextFreePort();
             using (var server = new SMTPServerSimulator(1, smtpServerPort))
             {
            server.AddRecipientResult(deliveryResults);
            server.StartListen();

            // Add a route pointing at localhost
            Route route = _settings.Routes.Add();
            route.DomainName = "test.com";
            route.TargetSMTPHost = "localhost";
            route.TargetSMTPPort = smtpServerPort;
            route.NumberOfTries = 1;
            route.MinutesBetweenTry = 5;
            route.TreatRecipientAsLocalDomain = true;
            route.TreatSenderAsLocalDomain = true;
            route.AllAddresses = true;
            route.Save();

            var smtpClient = new SMTPClientSimulator();

            var recipients = new List<string>()
               {
                  "[email protected]",
                  "[email protected]",
                  "[email protected]",
                  "[email protected]"
               };

            CustomAssert.IsTrue(smtpClient.Send("[email protected]", recipients, "Test", "Test message"));
            TestSetup.AssertRecipientsInDeliveryQueue(0);

            server.WaitForCompletion();

            CustomAssert.IsTrue(server.MessageData.Contains("Test message"));
            CustomAssert.AreEqual(deliveryResults.Count, server.RcptTosReceived);
             }
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:46,代码来源:Routes.cs


注:本文中的RegressionTests.Shared.SMTPClientSimulator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。