예제 #1
0
        public void TestDeliverToMyselfOnLocalPortAfterChangedLocalPort()
        {
            hMailServer.TCPIPPorts oPorts = _application.Settings.TCPIPPorts;
            for (int i = 0; i < oPorts.Count; i++)
            {
                hMailServer.TCPIPPort oTestPort = oPorts[i];
                if (oTestPort.Protocol == hMailServer.eSessionType.eSTIMAP)
                {
                    oTestPort.PortNumber = 14300;
                }
                else if (oTestPort.Protocol == hMailServer.eSessionType.eSTSMTP)
                {
                    oTestPort.PortNumber = 11000;
                }
                else if (oTestPort.Protocol == hMailServer.eSessionType.eSTPOP3)
                {
                    oTestPort.PortNumber = 2500;
                }

                oTestPort.Save();
            }

            _application.Stop();
            _application.Start();

            // Set up a server and start listening.
            Dictionary <string, int> deliveryResults = new Dictionary <string, int>();

            deliveryResults["*****@*****.**"] = 250;
            SMTPServerSimulator server = new SMTPServerSimulator(1, 25);

            server.AddRecipientResult(deliveryResults);
            server.StartListen();

            // Add a route so we can connect to localhost.
            AddRoutePointingAtLocalhost(5, 25, false);

            // Send message to this route.
            SMTPClientSimulator sim = new SMTPClientSimulator(false, 11000);

            sim.Send("*****@*****.**", "*****@*****.**", "Test", "Test message");


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

            Utilities.AssertRecipientsInDeliveryQueue(0, false);

            Assert.IsTrue(server.MessageData.Contains("Test message"));

            oPorts.SetDefault();
            _application.Stop();
            _application.Start();
        }
예제 #2
0
        private void buttonDefault_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(Strings.Localize("This operation will change the configuration of the TCP/IP ports to their default values. Are you sure you want to do this?"), EnumStrings.hMailServerAdministrator, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                hMailServer.Application app = APICreator.Application;

                hMailServer.TCPIPPorts tcpIPPorts = APICreator.TCPIPPortsSettings;
                tcpIPPorts.SetDefault();
                Marshal.ReleaseComObject(tcpIPPorts);

                LoadList();

                Instances.MainForm.RefreshCurrentNode(null);
            }
        }