예제 #1
0
        public void TestDeliverToServerNotSupportingEHLO()
        {
            CustomAssert.AreEqual(0, _status.UndeliveredMessages.Length);

            var deliveryResults = new Dictionary <string, int>()
            {
                { "*****@*****.**", 250 }
            };

            int smtpServerPort = TestSetup.GetNextFreePort();

            using (var server = new SMTPServerSimulator(1, smtpServerPort))
            {
                server.ServerSupportsEhlo = false;
                server.AddRecipientResult(deliveryResults);
                server.StartListen();

                // Add a route so we can conenct to localhost.
                SMTPClientTests.AddRoutePointingAtLocalhost(1, smtpServerPort, false, eConnectionSecurity.eCSNone);

                // Send message to this route.

                if (!SMTPClientSimulator.StaticSend("*****@*****.**", "*****@*****.**", "Test", "Test message"))
                {
                    CustomAssert.Fail("Delivery failed");
                }

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

                TestSetup.AssertRecipientsInDeliveryQueue(0, false);

                CustomAssert.IsTrue(server.MessageData.Contains("Test message"));
            }
        }
예제 #2
0
        public void ShouldBePossibleToSendToRouteWithTargetIPAddress()
        {
            // Set up a server listening on port 250 which accepts email for [email protected]
            var deliveryResults = new Dictionary <string, int>();

            deliveryResults["*****@*****.**"] = 250;

            int smtpServerPort = TestSetup.GetNextFreePort();

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

                Route route = SMTPClientTests.AddRoutePointingAtLocalhost(1, smtpServerPort, true, eConnectionSecurity.eCSNone);
                route.TargetSMTPHost = "127.0.0.1";
                route.Save();

                var smtpSimulator = new SMTPClientSimulator();
                CustomAssert.IsTrue(smtpSimulator.Send("*****@*****.**",
                                                       "*****@*****.**", "Mail 1", "Test message"));


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

                CustomAssert.IsTrue(server.MessageData.Contains("Test message"));
            }
        }
예제 #3
0
        public void TestSendExternalToExternalPermitted()
        {
            SecurityRange range =
                SingletonProvider <TestSetup> .Instance.GetApp().Settings.SecurityRanges.get_ItemByName("My computer");

            range.RequireSMTPAuthExternalToExternal = false;
            range.Save();


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

            deliveryResults["*****@*****.**"] = 250;

            int smtpServerPort = TestSetup.GetNextFreePort();

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

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

                var oSMTP = new SMTPClientSimulator();
                CustomAssert.IsTrue(oSMTP.Send("*****@*****.**",
                                               "*****@*****.**", "Mail 1", "Test message"));


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

                CustomAssert.IsTrue(server.MessageData.Contains("Test message"));
            }
        }
예제 #4
0
        public void DoNotUseStartTlsIfNotEnabledButAvailable()
        {
            // No valid recipients...
            var deliveryResults = new Dictionary <string, int>();

            deliveryResults["*****@*****.**"] = 250;

            int smtpServerPort = TestSetup.GetNextFreePort();

            using (var server = new SMTPServerSimulator(1, smtpServerPort, eConnectionSecurity.eCSSTARTTLSOptional))
            {
                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("*****@*****.**", "*****@*****.**", "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"));
            }
        }
예제 #5
0
        public void DomainAliasesShouldNotRewriteRecipientList()
        {
            DomainAlias oDA = _domain.DomainAliases.Add();

            oDA.AliasName = "dummy-example.com";
            oDA.Save();

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

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

            deliveryResults["*****@*****.**"] = 250;

            int smtpServerPort = TestSetup.GetNextFreePort();

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


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

                // Now send a message from [email protected] to [email protected].
                // Error scenario:
                // In the recipientlist, otherdomain.com gets rewritten to test.com
                // since there's a domain alias named otherdomain.co on the domain
                // test.com.
                //
                // This should not happen. Otherdomain.com is an alias for test.com,
                // but we shouldn't actually modify the recipient address just because
                // of this.
                var smtpClient = new SMTPClientSimulator();
                CustomAssert.IsTrue(smtpClient.Send(account.Address, "*****@*****.**", "Test", "Test message"));

                TestSetup.AssertRecipientsInDeliveryQueue(0);

                POP3ClientSimulator.AssertMessageCount(account.Address, "test", 0);

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

                CustomAssert.IsTrue(server.MessageData.Contains("Test message"));
            }
        }