Example #1
0
        public void TestSendToTooManyRecipients()
        {
            hMailServer.Accounts accounts      = _domain.Accounts;
            hMailServer.Account  senderAccount =
                SingletonProvider <Utilities> .Instance.AddAccount(accounts, string.Format("*****@*****.**"), "test");

            List <string> recipients = new List <string>();


            TCPSocket sock = new TCPSocket();

            sock.Connect(25);
            string result = sock.ReadUntil("\r\n");

            sock.Send("EHLO test.com\r\n");
            result = sock.ReadUntil("\r\n");
            Assert.IsTrue(result.StartsWith("250"));
            sock.Send("MAIL FROM: [email protected]\r\n");
            result = sock.ReadUntil("\r\n");
            Assert.IsTrue(result.StartsWith("250"));

            Stopwatch watch = new Stopwatch();

            watch.Start();

            for (int i = 0; i < 51000; i++)
            {
                string address = string.Format("test{0}@gmail.com", i);

                sock.Send(string.Format("RCPT TO: <{0}>\r\n", address));

                result = sock.ReadUntil("\r\n");
                if (i < 50000)
                {
                    Assert.IsTrue(result.StartsWith("250"));
                }
                else
                {
                    long perfor = watch.ElapsedMilliseconds;
                    Assert.IsFalse(result.StartsWith("250"));
                }
            }
        }
Example #2
0
        public void TestPOP3DownloadOfLargeMessage()
        {
            TestLongSMTPDataSessionIncludingNewline();

            POP3Simulator.AssertMessageCount("*****@*****.**", "test", 1);

            TCPSocket socket = new TCPSocket();

            socket.Connect(110);

            // Receive welcome message.
            string sData = socket.Receive();

            socket.Send("USER " + "*****@*****.**" + "\r\n");
            sData = socket.ReadUntil("+OK");

            socket.Send("PASS " + "test" + "\r\n");
            sData = socket.ReadUntil("+OK");

            socket.Send("RETR 1\r\n");

            string sRetVal = "";

            while (sRetVal.IndexOf("\r\n.\r\n") < 0)
            {
                if (sRetVal.IndexOf("-ERR no such message") >= 0)
                {
                    socket.Disconnect();
                    Assert.Fail("Nope");
                }

                sRetVal = socket.Receive();
            }

            socket.Send("DELE 1\r\n");
            sData = socket.ReadUntil("+OK");

            socket.Send("QUIT\r\n");
            sData = socket.ReadUntil("+OK");

            socket.Disconnect();
        }