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


C# SMTPClientSimulator.Send方法代码示例

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


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

示例1: 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

示例2: 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,
                                                                        "[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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例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: TestAliases

        public void TestAliases()
        {
            // Fetch default domain

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

             // Add aliases
             SingletonProvider<TestSetup>.Instance.AddAlias(_domain, "[email protected]", "[email protected]");
             SingletonProvider<TestSetup>.Instance.AddAlias(_domain, "[email protected]", "[email protected]");
             var oSMTP = new SMTPClientSimulator();

             // Spam folder
             oSMTP.Send("[email protected]", "[email protected]", "Mail 1", "Mail 1");
             oSMTP.Send("[email protected]", "[email protected]", "Mail 2", "Mail 2");
             oSMTP.Send("[email protected]", "[email protected]", "Mail 3", "Mail 3");

             IMAPSimulator.AssertMessageCount("[email protected]", "test", "Inbox", 3);
        }
开发者ID:jrallo,项目名称:hMailServer,代码行数:19,代码来源:Delivery.cs

示例11: 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

示例12: 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

示例13: TestMultipleDomains

        public void TestMultipleDomains()
        {
            Domains domains = SingletonProvider<TestSetup>.Instance.GetApp().Domains;

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

             Domain domain2 = SingletonProvider<TestSetup>.Instance.AddDomain(domains, "test2.com");

             Account account3 = SingletonProvider<TestSetup>.Instance.AddAccount(domain2, "[email protected]", "test");
             Account account4 = SingletonProvider<TestSetup>.Instance.AddAccount(domain2, "[email protected]", "test");

             var smtpSimulator = new SMTPClientSimulator();
             smtpSimulator.Send("[email protected]", account1.Address, "Test", "[email protected]");
             smtpSimulator.Send("[email protected]", account2.Address, "Test", "[email protected]");
             smtpSimulator.Send("[email protected]", account3.Address, "Test", "[email protected]");
             smtpSimulator.Send("[email protected]", account4.Address, "Test", "[email protected]");

             CustomAssert.IsTrue(POP3Simulator.AssertGetFirstMessageText(account1.Address, "test").Contains(account1.Address));
             CustomAssert.IsTrue(POP3Simulator.AssertGetFirstMessageText(account2.Address, "test").Contains(account2.Address));
             CustomAssert.IsTrue(POP3Simulator.AssertGetFirstMessageText(account3.Address, "test").Contains(account3.Address));
             CustomAssert.IsTrue(POP3Simulator.AssertGetFirstMessageText(account4.Address, "test").Contains(account4.Address));
        }
开发者ID:japi,项目名称:hmailserver,代码行数:23,代码来源:DomainServices.cs

示例14: TestGreyListing

        public void TestGreyListing()
        {
            _antiSpam.GreyListingEnabled = false;

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

             var smtp = new SMTPClientSimulator();
             var recipients = new List<string>();
             recipients.Add(oAccount1.Address);
             bool result = smtp.Send("[email protected]", recipients, "Test", "Body");
             CustomAssert.IsTrue(result);
             POP3ClientSimulator.AssertGetFirstMessageText(oAccount1.Address, "test");

             _antiSpam.GreyListingEnabled = true;

             result = smtp.Send("[email protected]", recipients, "Test", "Body");
             CustomAssert.IsFalse(result);

             _antiSpam.GreyListingEnabled = false;

             result = smtp.Send("[email protected]", recipients, "Test", "Body");
             CustomAssert.IsTrue(result);
             POP3ClientSimulator.AssertGetFirstMessageText(oAccount1.Address, "test");
        }
开发者ID:digitalsoft,项目名称:hmailserver,代码行数:24,代码来源:GreyListing.cs

示例15: 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


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