public bool SaveData() { if (_representedObject == null) { hMailServer.TCPIPPorts tcpIPPorts = APICreator.TCPIPPortsSettings; _representedObject = tcpIPPorts.Add(); Marshal.ReleaseComObject(tcpIPPorts); } _representedObject.Address = textIPAddress.Text; _representedObject.PortNumber = textTCPIPPort.Number; _representedObject.ConnectionSecurity = (eConnectionSecurity)comboConnectionSecurity.SelectedValue; _representedObject.Protocol = (hMailServer.eSessionType)comboProtocol.SelectedValue; if (comboSSLCertificate.SelectedValue == null) { _representedObject.SSLCertificateID = 0; } else { _representedObject.SSLCertificateID = (int)comboSSLCertificate.SelectedValue; } _representedObject.Save(); DirtyChecker.SetClean(this); Utility.RefreshNode(InternalNames.GetPortName(_representedObject)); Utility.AskRestartServer(); return(true); }
public ucTCPIPPort(int portID) { InitializeComponent(); DirtyChecker.SubscribeToChange(this, OnContentChanged); if (portID > 0) { hMailServer.TCPIPPorts ports = APICreator.TCPIPPortsSettings; _representedObject = ports.get_ItemByDBID(portID); Marshal.ReleaseComObject(ports); } comboProtocol.AddItem("SMTP", eSessionType.eSTSMTP); comboProtocol.AddItem("POP3", eSessionType.eSTPOP3); comboProtocol.AddItem("IMAP", eSessionType.eSTIMAP); comboConnectionSecurity.AddItems(ConnectionSecurityTypes.Get()); ListSSLCertificates(); new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); EnableDisable(); }
public ucTCPIPPort(int portID) { InitializeComponent(); DirtyChecker.SubscribeToChange(this, OnContentChanged); if (portID > 0) { hMailServer.TCPIPPorts ports = APICreator.TCPIPPortsSettings; _representedObject = ports.get_ItemByDBID(portID); Marshal.ReleaseComObject(ports); } comboProtocol.AddItem("SMTP", eSessionType.eSTSMTP); comboProtocol.AddItem("POP3", eSessionType.eSTPOP3); comboProtocol.AddItem("IMAP", eSessionType.eSTIMAP); comboConnectionSecurity.AddItems(ConnectionSecurityTypes.Get(true)); ListSSLCertificates(); new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); EnableDisable(); }
private void InternalSetupSMTPSSLPort() { hMailServer.SSLCertificate sslCeritifcate = SetupSSLCertificate(); hMailServer.TCPIPPort port = _application.Settings.TCPIPPorts.Add(); port.Address = "0.0.0.0"; port.PortNumber = 250; port.UseSSL = true; port.SSLCertificateID = sslCeritifcate.ID; port.Protocol = hMailServer.eSessionType.eSTSMTP; port.Save(); port = _application.Settings.TCPIPPorts.Add(); port.Address = "0.0.0.0"; port.PortNumber = 11000; port.UseSSL = true; port.SSLCertificateID = sslCeritifcate.ID; port.Protocol = hMailServer.eSessionType.eSTPOP3; port.Save(); port = _application.Settings.TCPIPPorts.Add(); port.Address = "0.0.0.0"; port.PortNumber = 14300; port.UseSSL = true; port.SSLCertificateID = sslCeritifcate.ID; port.Protocol = hMailServer.eSessionType.eSTIMAP; port.Save(); _application.Stop(); _application.Start(); }
public void SetupSSLCertificateWithPassword() { string originalPath = Environment.CurrentDirectory; Environment.CurrentDirectory = Environment.CurrentDirectory + "\\..\\..\\..\\SSL examples\\WithPassword"; string sslPath = Environment.CurrentDirectory; Environment.CurrentDirectory = originalPath; hMailServer.SSLCertificate sslCertificate = _application.Settings.SSLCertificates.Add(); sslCertificate.Name = "Example"; sslCertificate.CertificateFile = sslPath + "\\server.crt"; sslCertificate.PrivateKeyFile = sslPath + "\\server.key"; sslCertificate.Save(); hMailServer.TCPIPPort port = _application.Settings.TCPIPPorts.Add(); port.Address = "0.0.0.0"; port.PortNumber = 251; port.UseSSL = true; port.SSLCertificateID = sslCertificate.ID; port.Protocol = hMailServer.eSessionType.eSTSMTP; port.Save(); _application.Stop(); _application.Start(); Utilities.AssertReportedError(); }
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(); }
protected override void LoadList() { listObjects.Items.Clear(); hMailServer.TCPIPPorts tcpIPPorts = APICreator.TCPIPPortsSettings; for (int i = 0; i < tcpIPPorts.Count; i++) { hMailServer.TCPIPPort tcpIPPort = tcpIPPorts[i]; ListViewItem item = listObjects.Items.Add(InternalNames.GetPortName(tcpIPPort)); item.Tag = tcpIPPort.ID; Marshal.ReleaseComObject(tcpIPPort); } Marshal.ReleaseComObject(tcpIPPorts); }
public bool SaveData() { if (_representedObject == null) { hMailServer.TCPIPPorts tcpIPPorts = APICreator.TCPIPPortsSettings; _representedObject = tcpIPPorts.Add(); Marshal.ReleaseComObject(tcpIPPorts); } _representedObject.Address = textIPAddress.Text; _representedObject.PortNumber = textTCPIPPort.Number; _representedObject.UseSSL = checkEnableSSL.Checked; _representedObject.Protocol = (hMailServer.eSessionType)comboProtocol.SelectedValue; if (comboSSLCertificate.SelectedValue == null) { _representedObject.SSLCertificateID = 0; } else { _representedObject.SSLCertificateID = (int)comboSSLCertificate.SelectedValue; } _representedObject.Save(); DirtyChecker.SetClean(this); Utility.RefreshNode(InternalNames.GetPortName(_representedObject)); if (MessageBox.Show(Strings.Localize("hMailServer needs to be restarted for the changes to take effect.") + Environment.NewLine + Strings.Localize("Do you want to restart hMailServer now?"), EnumStrings.hMailServerAdministrator, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { using (new WaitCursor()) { hMailServer.Application application = APICreator.Application; application.Stop(); application.Start(); MessageBox.Show(Strings.Localize("The hMailServer server has been restarted."), EnumStrings.hMailServerAdministrator, MessageBoxButtons.OK, MessageBoxIcon.Information); } } return(true); }
public static string GetPortName(hMailServer.TCPIPPort port) { string ipAddress = port.Address; string portNumber = port.PortNumber.ToString(); string protocolName = ""; switch (port.Protocol) { case eSessionType.eSTIMAP: protocolName = "IMAP"; break; case eSessionType.eSTPOP3: protocolName = "POP3"; break; case eSessionType.eSTSMTP: protocolName = "SMTP"; break; } return(ipAddress + " / " + portNumber + " / " + protocolName); }
public bool SaveData() { if (_representedObject == null) { hMailServer.TCPIPPorts tcpIPPorts = APICreator.TCPIPPortsSettings; _representedObject = tcpIPPorts.Add(); Marshal.ReleaseComObject(tcpIPPorts); } _representedObject.Address = textIPAddress.Text; _representedObject.PortNumber = textTCPIPPort.Number; _representedObject.ConnectionSecurity = (eConnectionSecurity) comboConnectionSecurity.SelectedValue; _representedObject.Protocol = (hMailServer.eSessionType)comboProtocol.SelectedValue; if (comboSSLCertificate.SelectedValue == null) _representedObject.SSLCertificateID = 0; else _representedObject.SSLCertificateID = (int)comboSSLCertificate.SelectedValue; _representedObject.Save(); DirtyChecker.SetClean(this); Utility.RefreshNode(InternalNames.GetPortName(_representedObject)); if (MessageBox.Show(Strings.Localize("hMailServer needs to be restarted for the changes to take effect.") + Environment.NewLine + Strings.Localize("Do you want to restart hMailServer now?"), EnumStrings.hMailServerAdministrator, MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.Yes) { using (new WaitCursor()) { hMailServer.Application application = APICreator.Application; application.Stop(); application.Start(); MessageBox.Show(Strings.Localize("The hMailServer server has been restarted."), EnumStrings.hMailServerAdministrator, MessageBoxButtons.OK, MessageBoxIcon.Information); } } return true; }
public void TestPortOpening() { hMailServer.Application oApp = SingletonProvider <Utilities> .Instance.GetApp(); oApp.Settings.TCPIPPorts.SetDefault(); SMTPClientSimulator pSMTPSimulator = new SMTPClientSimulator(); POP3Simulator pPOP3Simulator = new POP3Simulator(); IMAPSimulator pIMAPSimulator = new IMAPSimulator(); oApp.Stop(); hMailServer.TCPIPPorts oPorts = oApp.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(); } oApp.Start(); Assert.IsTrue(pSMTPSimulator.TestConnect(2500)); Assert.IsTrue(pSMTPSimulator.TestConnect(11000)); Assert.IsTrue(pSMTPSimulator.TestConnect(14300)); oApp.Stop(); hMailServer.TCPIPPort oPort = oApp.Settings.TCPIPPorts.Add(); oPort.Protocol = hMailServer.eSessionType.eSTSMTP; oPort.PortNumber = 25000; oPort.Save(); oApp.Start(); // Try to connect to the new port Assert.IsTrue(pSMTPSimulator.TestConnect(25000)); oApp.Stop(); // Delete the port again oApp.Settings.TCPIPPorts.DeleteByDBID(oPort.ID); // Change back the ports for (int i = 0; i < oPorts.Count; i++) { hMailServer.TCPIPPort oTestPort = oPorts[i]; if (oTestPort.Protocol == hMailServer.eSessionType.eSTIMAP) { oTestPort.PortNumber = 143; } else if (oTestPort.Protocol == hMailServer.eSessionType.eSTSMTP) { oTestPort.PortNumber = 25; } else if (oTestPort.Protocol == hMailServer.eSessionType.eSTPOP3) { oTestPort.PortNumber = 110; } oTestPort.Save(); } oApp.Start(); Assert.IsTrue(pSMTPSimulator.TestConnect(25)); Assert.IsTrue(pPOP3Simulator.TestConnect(110)); Assert.IsTrue(pPOP3Simulator.TestConnect(143)); }
public bool SaveData() { if (_representedObject == null) { hMailServer.TCPIPPorts tcpIPPorts = APICreator.TCPIPPortsSettings; _representedObject = tcpIPPorts.Add(); Marshal.ReleaseComObject(tcpIPPorts); } _representedObject.Address = textIPAddress.Text; _representedObject.PortNumber = textTCPIPPort.Number; _representedObject.ConnectionSecurity = (eConnectionSecurity) comboConnectionSecurity.SelectedValue; _representedObject.Protocol = (hMailServer.eSessionType)comboProtocol.SelectedValue; if (comboSSLCertificate.SelectedValue == null) _representedObject.SSLCertificateID = 0; else _representedObject.SSLCertificateID = (int)comboSSLCertificate.SelectedValue; _representedObject.Save(); DirtyChecker.SetClean(this); Utility.RefreshNode(InternalNames.GetPortName(_representedObject)); Utility.AskRestartServer(); return true; }