public AutoreplyService(AutoreplyServiceConfiguration configuration = null)
        {
            configuration = configuration ?? AutoreplyServiceConfiguration.GetSection();

            _storeIncomingMail = configuration.IsDebug;

            _mailFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), configuration.MailFolder);
            if (!Directory.Exists(_mailFolder))
            {
                Directory.CreateDirectory(_mailFolder);
            }

            _smtpServer = new SMTP_Server
            {
                MaxBadCommands      = configuration.SmtpConfiguration.MaxBadCommands,
                MaxTransactions     = configuration.SmtpConfiguration.MaxTransactions,
                MaxMessageSize      = configuration.SmtpConfiguration.MaxMessageSize,
                MaxRecipients       = configuration.SmtpConfiguration.MaxRecipients,
                MaxConnectionsPerIP = configuration.SmtpConfiguration.MaxConnectionsPerIP,
                MaxConnections      = configuration.SmtpConfiguration.MaxConnections,
                Bindings            = new[] { new IPBindInfo("localhost", IPAddress.Any, configuration.SmtpConfiguration.Port, SslMode.None, null) },
            };

            _smtpServer.Error          += OnSmtpError;
            _smtpServer.SessionCreated += OnSmtpSessionCreated;

            _cooldownInspector = new CooldownInspector(configuration.CooldownConfiguration);

            _apiService = new ApiService(configuration.Https);
        }
        public AutoreplyService(AutoreplyServiceConfiguration configuration = null)
        {
            configuration = configuration ?? AutoreplyServiceConfiguration.GetSection();

            _storeIncomingMail = configuration.IsDebug;

            _mailFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), configuration.MailFolder);
            if (!Directory.Exists(_mailFolder))
                Directory.CreateDirectory(_mailFolder);

            _smtpServer = new SMTP_Server
                {
                    MaxBadCommands = configuration.SmtpConfiguration.MaxBadCommands,
                    MaxTransactions = configuration.SmtpConfiguration.MaxTransactions,
                    MaxMessageSize = configuration.SmtpConfiguration.MaxMessageSize,
                    MaxRecipients = configuration.SmtpConfiguration.MaxRecipients,
                    MaxConnectionsPerIP = configuration.SmtpConfiguration.MaxConnectionsPerIP,
                    MaxConnections = configuration.SmtpConfiguration.MaxConnections,
                    Bindings = new[] {new IPBindInfo("localhost", IPAddress.Any, configuration.SmtpConfiguration.Port, SslMode.None, null)},
                };

            _smtpServer.Error += OnSmtpError;
            _smtpServer.SessionCreated += OnSmtpSessionCreated;

            _cooldownInspector = new CooldownInspector(configuration.CooldownConfiguration);

            _apiService = new ApiService(configuration.Https);
        }