예제 #1
0
        /// <summary>
        /// Get the smtp server information from
        /// the configuration file, the host and
        /// port of the smtp server is located in
        /// the default section, this data is used
        /// to connect to the smtp server.
        /// </summary>
        private void GetSmtpServerHost()
        {
            try
            {
                // Create a new connection adapter.
                _connection = new SmtpConnectionAdapter();

                // If no host name set then
                // use the defualt values.
                if (String.IsNullOrEmpty(_smtpServerName))
                {
                    // Create a new default host type
                    // an load the values from the configuration
                    // file into the default host type.
                    ProxySmtpServerDefaultHost defaultHost =
                        (ProxySmtpServerDefaultHost)System.Configuration.ConfigurationManager.GetSection(
                            "ProxySmtpServerGroup/ProxySmtpServerDefaultHost");

                    // If the port is greater than zero then
                    // assign the port number.
                    if (defaultHost.HostSection.PortAttribute > 0)
                    {
                        _connection.Port = defaultHost.HostSection.PortAttribute;
                    }

                    // Get the smtp server.
                    _connection.Server = defaultHost.HostSection.HostAttribute;
                }
                else
                {
                    // Create a new host type
                    // an load the values from the configuration
                    // file into the host type.
                    ProxySmtpServerHosts hosts =
                        (ProxySmtpServerHosts)System.Configuration.ConfigurationManager.GetSection(
                            "ProxySmtpServerGroup/ProxySmtpServerHosts");

                    // If the port is greater than zero then
                    // assign the port number.
                    if (hosts.HostSection[_smtpServerName].PortAttribute > 0)
                    {
                        _connection.Port = hosts.HostSection[_smtpServerName].PortAttribute;
                    }

                    // Get the smtp server.
                    _connection.Server = hosts.HostSection[_smtpServerName].HostAttribute;
                }
            }
            catch (Exception e)
            {
                // Detect a thread abort exception.
                if (e is ThreadAbortException)
                {
                    Thread.ResetAbort();
                }

                base.Write("SmtpTlsProxyServer", "GetListeningPort", e.Message,
                           246, WriteTo.EventLog, LogType.Error);
            }
        }
예제 #2
0
        /// <summary>
        /// Get the maximum number of clients from the configuration
        /// file, if no value is specified then default or
        /// the current value will be used.
        /// </summary>
        private void GetMaxNumClients()
        {
            try
            {
                // If no host name set then
                // use the defualt values.
                if (String.IsNullOrEmpty(_hostName))
                {
                    // Create a new default host type
                    // an load the values from the configuration
                    // file into the default host type.
                    ProxySmtpServerDefaultHost defaultHost =
                        (ProxySmtpServerDefaultHost)System.Configuration.ConfigurationManager.GetSection(
                            "ProxySmtpServerGroup/ProxySmtpServerDefaultHost");

                    // If the value is greater than zero then
                    // assign the port number.
                    if (defaultHost.HostSection.MaxNumClientsAttribute > 0)
                    {
                        _maxNumClients = defaultHost.HostSection.MaxNumClientsAttribute;
                    }
                }
                else
                {
                    // Create a new host type
                    // an load the values from the configuration
                    // file into the host type.
                    ProxySmtpServerHosts hosts =
                        (ProxySmtpServerHosts)System.Configuration.ConfigurationManager.GetSection(
                            "ProxySmtpServerGroup/ProxySmtpServerHosts");

                    // If the value is greater than zero then
                    // assign the port number.
                    if (hosts.HostSection[_hostName].MaxNumClientsAttribute > 0)
                    {
                        _maxNumClients = hosts.HostSection[_hostName].MaxNumClientsAttribute;
                    }
                }

                // Create a new client array.
                _client = new SmtpTlsProxyConnection[_maxNumClients];
            }
            catch (Exception e)
            {
                // Detect a thread abort exception.
                if (e is ThreadAbortException)
                {
                    Thread.ResetAbort();
                }

                base.Write("SmtpTlsProxyServer", "GetMaxNumClients", e.Message,
                           246, WriteTo.EventLog, LogType.Error);
            }
        }