public static void SetupSSLPorts(hMailServer.Application application, SslVersions sslVersions = null) { SSLCertificate sslCeritifcate = SetupSSLCertificate(application); var settings = application.Settings; var ports = settings.TCPIPPorts; ports.SetDefault(); AddPort(ports, 25000, eConnectionSecurity.eCSNone, sslCeritifcate.ID, eSessionType.eSTSMTP); AddPort(ports, 11000, eConnectionSecurity.eCSNone, sslCeritifcate.ID, eSessionType.eSTPOP3); AddPort(ports, 14300, eConnectionSecurity.eCSNone, sslCeritifcate.ID, eSessionType.eSTIMAP); AddPort(ports, 25001, eConnectionSecurity.eCSTLS, sslCeritifcate.ID, eSessionType.eSTSMTP); AddPort(ports, 11001, eConnectionSecurity.eCSTLS, sslCeritifcate.ID, eSessionType.eSTPOP3); AddPort(ports, 14301, eConnectionSecurity.eCSTLS, sslCeritifcate.ID, eSessionType.eSTIMAP); AddPort(ports, 25002, eConnectionSecurity.eCSSTARTTLSOptional, sslCeritifcate.ID, eSessionType.eSTSMTP); AddPort(ports, 11002, eConnectionSecurity.eCSSTARTTLSOptional, sslCeritifcate.ID, eSessionType.eSTPOP3); AddPort(ports, 14302, eConnectionSecurity.eCSSTARTTLSOptional, sslCeritifcate.ID, eSessionType.eSTIMAP); AddPort(ports, 25003, eConnectionSecurity.eCSSTARTTLSRequired, sslCeritifcate.ID, eSessionType.eSTSMTP); AddPort(ports, 11003, eConnectionSecurity.eCSSTARTTLSRequired, sslCeritifcate.ID, eSessionType.eSTPOP3); AddPort(ports, 14303, eConnectionSecurity.eCSSTARTTLSRequired, sslCeritifcate.ID, eSessionType.eSTIMAP); settings.SslVersion30Enabled = sslVersions == null || sslVersions.Ssl30; settings.TlsVersion10Enabled = sslVersions == null || sslVersions.Tls10; settings.TlsVersion11Enabled = sslVersions == null || sslVersions.Tls11; settings.TlsVersion12Enabled = sslVersions == null || sslVersions.Tls12; application.Stop(); application.Start(); }
public static bool AuthenticateUser(hMailServer.Application application) { // First try to authenticate using an empty password. if (AuthenticateUser(application, "")) return true; // Try to authenticate using password on command line... string [] args = Environment.GetCommandLineArgs(); foreach (string password in args) { if (AuthenticateUser(application, password)) return true; } while (true) { formEnterPassword passwordDlg = new formEnterPassword(); if (passwordDlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) return false; string password = passwordDlg.Password; if (AuthenticateUser(application, password)) return true; MessageBox.Show("Invalid user name or password.", "hMailServer"); } }
public formMain(hMailServer.Application application) { InitializeComponent(); _application = application; _databaseType = null; }
public void SaveProperties(hMailServer.WhiteListAddress address) { address.LowerIPAddress = textLowerIP.Text; address.UpperIPAddress = textUpperIP.Text; address.Description = textDescription.Text; address.EmailAddress = textEmailAddress.Text; }
public void LoadProperties(hMailServer.WhiteListAddress address) { textLowerIP.Text = address.LowerIPAddress; textUpperIP.Text = address.UpperIPAddress; textDescription.Text = address.Description; textEmailAddress.Text = address.EmailAddress; }
public static void SetupSSLPorts(hMailServer.Application application) { SSLCertificate sslCeritifcate = SetupSSLCertificate(application); var ports = application.Settings.TCPIPPorts; AddPort(ports, 25000, eConnectionSecurity.eCSNone, sslCeritifcate.ID, eSessionType.eSTSMTP); AddPort(ports, 11000, eConnectionSecurity.eCSNone, sslCeritifcate.ID, eSessionType.eSTPOP3); AddPort(ports, 14300, eConnectionSecurity.eCSNone, sslCeritifcate.ID, eSessionType.eSTIMAP); AddPort(ports, 25001, eConnectionSecurity.eCSTLS, sslCeritifcate.ID, eSessionType.eSTSMTP); AddPort(ports, 11001, eConnectionSecurity.eCSTLS, sslCeritifcate.ID, eSessionType.eSTPOP3); AddPort(ports, 14301, eConnectionSecurity.eCSTLS, sslCeritifcate.ID, eSessionType.eSTIMAP); AddPort(ports, 25002, eConnectionSecurity.eCSSTARTTLSOptional, sslCeritifcate.ID, eSessionType.eSTSMTP); AddPort(ports, 11002, eConnectionSecurity.eCSSTARTTLSOptional, sslCeritifcate.ID, eSessionType.eSTPOP3); AddPort(ports, 14302, eConnectionSecurity.eCSSTARTTLSOptional, sslCeritifcate.ID, eSessionType.eSTIMAP); AddPort(ports, 25003, eConnectionSecurity.eCSSTARTTLSRequired, sslCeritifcate.ID, eSessionType.eSTSMTP); AddPort(ports, 11003, eConnectionSecurity.eCSSTARTTLSRequired, sslCeritifcate.ID, eSessionType.eSTPOP3); AddPort(ports, 14303, eConnectionSecurity.eCSSTARTTLSRequired, sslCeritifcate.ID, eSessionType.eSTIMAP); application.Stop(); application.Start(); }
public static void SetupSSLPorts(hMailServer.Application application, eConnectionSecurity security) { SSLCertificate sslCeritifcate = SetupSSLCertificate(application); TCPIPPort port = application.Settings.TCPIPPorts.Add(); port.Address = "0.0.0.0"; port.PortNumber = 250; port.ConnectionSecurity = security; port.SSLCertificateID = sslCeritifcate.ID; port.Protocol = eSessionType.eSTSMTP; port.Save(); port = application.Settings.TCPIPPorts.Add(); port.Address = "0.0.0.0"; port.PortNumber = 11000; port.ConnectionSecurity = security; port.SSLCertificateID = sslCeritifcate.ID; port.Protocol = eSessionType.eSTPOP3; port.Save(); port = application.Settings.TCPIPPorts.Add(); port.Address = "0.0.0.0"; port.PortNumber = 14300; port.ConnectionSecurity = security; port.SSLCertificateID = sslCeritifcate.ID; port.Protocol = eSessionType.eSTIMAP; port.Save(); application.Stop(); application.Start(); }
public ucAccounts(hMailServer.Domain domain) { InitializeComponent(); representedDomain = domain; new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); }
public static bool AuthenticateUser(hMailServer.Application application, string password) { hMailServer.Account account = application.Authenticate("Administrator", password); if (account != null) return true; return false; }
public formAccountFolders(hMailServer.IMAPFolders imapFolders, bool publicFolders) { InitializeComponent(); ucIMAPFolders1.LoadProperties(imapFolders, publicFolders); new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); Strings.Localize(this.buttonClose); this.Text = Strings.Localize(this.Text); ucIMAPFolders1.Localize(); }
public ucDomain(hMailServer.Domain domain) { InitializeComponent(); _domain = domain; EnableDisableTabs(); DirtyChecker.SubscribeToChange(this, OnContentChanged); new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); EnableDisable(); }
public static string GetAdministrationLevelName(hMailServer.eAdminLevel level) { switch (level) { case eAdminLevel.hAdminLevelNormal: return Strings.Localize("User"); case eAdminLevel.hAdminLevelDomainAdmin: return Strings.Localize("Domain"); case eAdminLevel.hAdminLevelServerAdmin: return Strings.Localize("Server"); } throw new Exception("Unknown administration level"); }
public formRuleAction(hMailServer.Rule rule, hMailServer.RuleAction ruleAction) { InitializeComponent(); _ruleAction = ruleAction; _isAccountLevelRule = rule.AccountID > 0; FillCombo(); LoadProperties(); new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); Strings.Localize(this); }
public formRuleCriteria(hMailServer.RuleCriteria ruleCriteria) { InitializeComponent(); _ruleCriteria = ruleCriteria; FillCombos(); LoadProperties(); new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); Strings.Localize(this); _utilities = APICreator.Application.Utilities; }
public formMain(hMailServer.Application app, string serverHost) { InitializeComponent(); application = app; _serverHost = serverHost; currentlySelectedNode = null; _language = "English"; LoadWindowSettings(); _language = Strings.LoadLanguage(_language); Strings.Localize(this); }
public formFolderPermissions(hMailServer.IMAPFolder folder) { InitializeComponent(); EnableDisable(); _folder = folder; ListPermissions(); new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); labelPermissionsFor.Text = ""; Strings.Localize(this); }
public static string GetDatabaseServerTypeName(hMailServer.eDBtype dbType) { switch (dbType) { case eDBtype.hDBTypeMSSQL: return "MSSQL"; case eDBtype.hDBTypeMSSQLCE: return "MSSQL CE"; case eDBtype.hDBTypeMySQL: return "MySQL"; case eDBtype.hDBTypePostgreSQL: return "PostgreSQL"; case eDBtype.hDBTypeUnknown: return "Unknown"; } throw new Exception("Unknown administration level"); }
public formRule(hMailServer.Rule rule) { InitializeComponent(); _rule = rule; this.DialogResult = DialogResult.None; LoadRuleProperties(); ListRuleCriterias(); ListRuleActions(); new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); DirtyChecker.SubscribeToChange(this, OnContentChanged); Strings.Localize(this); EnableDisable(); }
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; }
private static SSLCertificate SetupSSLCertificate(hMailServer.Application application) { var sslPath = GetSslCertPath(); var exampleCert = Path.Combine(sslPath, "example.crt"); var exampleKey = Path.Combine(sslPath, "example.key"); if (!File.Exists(exampleCert)) CustomAssert.Fail("Certificate " + exampleCert + " was not found"); if (!File.Exists(exampleKey)) CustomAssert.Fail("Private key " + exampleKey + " was not found"); SSLCertificate sslCertificate = application.Settings.SSLCertificates.Add(); sslCertificate.Name = "Example"; sslCertificate.CertificateFile = exampleCert; sslCertificate.PrivateKeyFile = exampleKey; sslCertificate.Save(); return sslCertificate; }
public void LoadAccountProperties(hMailServer.FetchAccount fetchAccount) { _isLoading = true; _fetchAccount = fetchAccount; checkEnabled.Checked = fetchAccount.Enabled; textName.Text = fetchAccount.Name; textMinutesBetweenFetch.Number = fetchAccount.MinutesBetweenFetch; comboServerType.SelectedValue = fetchAccount.ServerType; textServer.Text = fetchAccount.ServerAddress; textPort.Number = fetchAccount.Port; textUsername.Text = fetchAccount.Username; comboConnectionSecurity.SelectedValue = fetchAccount.ConnectionSecurity; checkProcessMIMERecipients.Checked = fetchAccount.ProcessMIMERecipients; checkProcessMIMEDate.Checked = fetchAccount.ProcessMIMEDate; checkUseAntiSpam.Checked = fetchAccount.UseAntiSpam; checkUseAntiVirus.Checked = fetchAccount.UseAntiVirus; checkEnableRouteRecipients.Checked = fetchAccount.EnableRouteRecipients; if (fetchAccount.DaysToKeepMessages == -1) radioDeleteImmediately.Checked = true; else if (fetchAccount.DaysToKeepMessages == 0) radioNeverDeleteMessages.Checked = true; else { radioDeleteMessagesAfter.Checked = true; textDaysToKeepMessages.Number = fetchAccount.DaysToKeepMessages; } buttonDownloadNow.Enabled = true; _isLoading = false; EnableDisable(); }
public void LoadProperties(hMailServer.IMAPFolders imapFolders, bool publicFolders) { _folderHierarchyDelimiter = Utilities.APICreator.Settings.IMAPHierarchyDelimiter; btnEditPermissions.Visible = publicFolders; _folders = imapFolders; for (int i = 0; i < _folders.Count; i++) { hMailServer.IMAPFolder folder = _folders[i]; TreeNode node = treeFolders.Nodes.Add(folder.Name); node.Tag = folder; LoadSubFolders(folder, node); } if (treeFolders.Nodes.Count > 0) treeFolders.SelectedNode = treeFolders.Nodes[0]; ShowCurrentFolder(); }
private static SSLCertificate SetupSSLCertificate(hMailServer.Application application) { string originalPath = Environment.CurrentDirectory; Environment.CurrentDirectory = Environment.CurrentDirectory + "\\..\\..\\..\\SSL examples"; string sslPath = Environment.CurrentDirectory; Environment.CurrentDirectory = originalPath; var exampleCert = Path.Combine(sslPath, "example.crt"); var exampleKey = Path.Combine(sslPath, "example.key"); if (!File.Exists(exampleCert)) CustomAssert.Fail("Certificate " + exampleCert + " was not found"); if (!File.Exists(exampleKey)) CustomAssert.Fail("Private key " + exampleKey + " was not found"); SSLCertificate sslCertificate = application.Settings.SSLCertificates.Add(); sslCertificate.Name = "Example"; sslCertificate.CertificateFile = exampleCert; sslCertificate.PrivateKeyFile = exampleKey; sslCertificate.Save(); return sslCertificate; }
public void LoadProperties(hMailServer.GreyListingWhiteAddress whiteAddress) { textIPAddress.Text = whiteAddress.IPAddress; textDescription.Text = whiteAddress.Description; }
private void HandleUpgradeError(hMailServer.Database database, Exception error, string scriptToExecute) { try { database.RollbackTransaction(); } catch (Exception) { // When an error occurs in MSSQL, the rollback will be done // automatically. Hence it's not always an error that we cannot // rollback. // // Maybe we should check the actual cause of the rollback failure... // } finally { MessageBox.Show(error.Message, scriptToExecute); } buttonClose.Enabled = true; return; }
private void LoadSubFolders(hMailServer.IMAPFolder folder, TreeNode node) { hMailServer.IMAPFolders folders = folder.SubFolders; for (int i = 0; i < folders.Count; i++) { hMailServer.IMAPFolder subFolder = folders[i]; TreeNode subNode = node.Nodes.Add(subFolder.Name); subNode.Tag = subFolder; LoadSubFolders(subFolder, subNode); } }
public static void SetApp(hMailServer.Application application) { _application = application; }
public void SaveProperties(hMailServer.BlockedAttachment ba) { ba.Description = textDescription.Text; ba.Wildcard = textWildcard.Text; }
public void LoadProperties(hMailServer.BlockedAttachment ba) { textDescription.Text = ba.Description; textWildcard.Text = ba.Wildcard; }
public void SaveProperties(hMailServer.GreyListingWhiteAddress whiteAddress) { whiteAddress.IPAddress = textIPAddress.Text; whiteAddress.Description = textDescription.Text; }