Пример #1
0
        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();
        }
Пример #2
0
        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");
             }
        }
Пример #3
0
        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;
 }
Пример #6
0
        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();
        }
Пример #7
0
        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();
        }
Пример #8
0
        public ucAccounts(hMailServer.Domain domain)
        {
            InitializeComponent();

             representedDomain = domain;

             new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);
        }
Пример #9
0
        public static bool AuthenticateUser(hMailServer.Application application, string password)
        {
            hMailServer.Account account = application.Authenticate("Administrator", password);

             if (account != null)
            return true;

             return false;
        }
Пример #10
0
        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();
        }
Пример #11
0
        public ucDomain(hMailServer.Domain domain)
        {
            InitializeComponent();

            _domain = domain;

            EnableDisableTabs();

            DirtyChecker.SubscribeToChange(this, OnContentChanged);

            new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);

            EnableDisable();
        }
Пример #12
0
        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");
        }
Пример #13
0
        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);
        }
Пример #14
0
        public formRuleCriteria(hMailServer.RuleCriteria ruleCriteria)
        {
            InitializeComponent();

            _ruleCriteria = ruleCriteria;

            FillCombos();
            LoadProperties();

            new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);
            Strings.Localize(this);

            _utilities = APICreator.Application.Utilities;
        }
Пример #15
0
        public formMain(hMailServer.Application app, string serverHost)
        {
            InitializeComponent();

            application = app;
            _serverHost = serverHost;
            currentlySelectedNode = null;

            _language = "English";

            LoadWindowSettings();

            _language = Strings.LoadLanguage(_language);
            Strings.Localize(this);
        }
Пример #16
0
        public formFolderPermissions(hMailServer.IMAPFolder folder)
        {
            InitializeComponent();

            EnableDisable();

            _folder = folder;

            ListPermissions();

            new TabOrderManager(this).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);

            labelPermissionsFor.Text = "";
            Strings.Localize(this);
        }
Пример #17
0
        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");
        }
Пример #18
0
        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();
        }
Пример #19
0
        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;
        }
Пример #20
0
        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;
        }
Пример #21
0
        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();
        }
Пример #22
0
        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();
        }
Пример #23
0
        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;
 }
Пример #25
0
        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;
        }
Пример #26
0
        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);
             }
        }
Пример #27
0
 public static void SetApp(hMailServer.Application application)
 {
    _application = application;
 }
Пример #28
0
 public void SaveProperties(hMailServer.BlockedAttachment ba)
 {
     ba.Description = textDescription.Text;
      ba.Wildcard = textWildcard.Text;
 }
Пример #29
0
 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;
 }