Summary description for SMTPSimulator.
コード例 #1
0
 private void SendMessageThread()
 {
     for (int message = 0; message < _threadedMessageCount; message++)
     {
         SMTPSimulator.StaticSend("*****@*****.**", "*****@*****.**", "test", "test");
     }
 }
コード例 #2
0
ファイル: Worker.cs プロジェクト: SorenRR/hmailserver
 public static void DoWork()
 {
     while (true)
     {
         SMTPSimulator oSimulator = new SMTPSimulator();
         oSimulator.TestConnect();
     }
 }
コード例 #3
0
ファイル: Worker.cs プロジェクト: SpivEgin/hmailserver
 public static void DoWork()
 {
     while (true)
     {
         SMTPSimulator oSimulator = new SMTPSimulator();
         oSimulator.TestConnect();
     }
 }
コード例 #4
0
        public void TestLargeDistributionList()
        {
            // Add distribution list
            hMailServer.Accounts accounts = _domain.Accounts;

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

            for (int i = 0; i < 1000; i++)
            {
                hMailServer.Account account =
                    SingletonProvider <Utilities> .Instance.AddAccount(accounts, string.Format("recipient{0}@test.com", i), "test");

                recipients.Add(account.Address);

                Marshal.ReleaseComObject(account);
            }

            Marshal.ReleaseComObject(accounts);

            SingletonProvider <Utilities> .Instance.AddDistributionList(_domain, "*****@*****.**", recipients);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            SMTPSimulator.StaticSend("*****@*****.**", "*****@*****.**", "Test", "Test message");
            sw.Stop();

            Console.WriteLine("Elapsed time: " + sw.Elapsed.TotalSeconds.ToString());

            string dataDir =
                Path.Combine(SingletonProvider <Utilities> .Instance.GetApp().Settings.Directories.DataDirectory, "test.com");

            // Check number of accounts.
            int secondsToWait = 60;

            while (secondsToWait > 0)
            {
                try
                {
                    if (IsFolderCountReached(dataDir, 1000))
                    {
                        break;
                    }
                }
                catch (Exception)
                {
                }

                System.Threading.Thread.Sleep(10000);

                secondsToWait -= 5;
            }

            Assert.IsTrue(IsFolderCountReached(dataDir, 1000));

            _domain.Delete();

            Marshal.ReleaseComObject(_domain);
        }
コード例 #5
0
        public void SingleThread()
        {
            hMailServer.Account account =
                SingletonProvider <Utilities> .Instance.AddAccount(_domain.Accounts, "*****@*****.**", "test");

            for (int i = 0; i < 15; i++)
            {
                SMTPSimulator.StaticSend("*****@*****.**", "*****@*****.**", "test", "test");
            }

            POP3Simulator.AssertMessageCount(account.Address, "test", 15);

            for (int i = 0; i < 15; i++)
            {
                string content = POP3Simulator.AssertGetFirstMessageText(account.Address, "test");

                Assert.IsTrue(content.Contains("X-Spam-Status"), content);
            }
        }
コード例 #6
0
        public void TestSendLargeBatch()
        {
            hMailServer.Accounts accounts = _domain.Accounts;
            hMailServer.Account  account  =
                SingletonProvider <Utilities> .Instance.AddAccount(accounts, string.Format("*****@*****.**"), "test");

            string dataDir =
                Path.Combine(SingletonProvider <Utilities> .Instance.GetApp().Settings.Directories.DataDirectory, "test.com");

            string accountDir = Path.Combine(dataDir, "test");

            int memoryUsage    = Shared.GetCurrentMemoryUsage();
            int maxMemoryUsage = memoryUsage + 5;

            const int numberOfMessages = 200000;

            for (int i = 0; i < numberOfMessages; i++)
            {
                Assert.IsTrue(SMTPSimulator.StaticSend("*****@*****.**", "*****@*****.**", "Test", "Test message"));

                if (i % 100 == 0)
                {
                    Shared.AssertLowMemoryUsage(maxMemoryUsage);
                }
            }

            // Check number of delivered messages.
            while (true)
            {
                if (GetNumberOfFilesInFolder(accountDir) == numberOfMessages)
                {
                    break;
                }

                Shared.AssertLowMemoryUsage(maxMemoryUsage);

                System.Threading.Thread.Sleep(60 * 1000);
            }

            _domain.Delete();
        }