Пример #1
0
        public void Start()
        {
            _cancellationTokenSource = new CancellationTokenSource();

            var telegramSettings = TelegramConfiguration.Read();
            var telegram         = new TelegramAsMessageStore(telegramSettings.Token, telegramSettings.ChatId);

            var smtpSettings = SmtpConfiguration.Read();
            var options      = new SmtpServer.SmtpServerOptionsBuilder()
                               .Port(smtpSettings.Port)
                               .MessageStore(telegram)
                               .Build();
            var smtpServer = new SmtpServer.SmtpServer(options);

            _ = smtpServer.StartAsync(_cancellationTokenSource.Token);

            if (Environment.UserInteractive)
            {
                _log.Warn($"{ServiceName} started in interactive mode");
            }
            else
            {
                _log.Warn($"{ServiceName} service started");
            }
        }
Пример #2
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            _logger.LogInformation("SMTP Server started.");

            await _smtpServer.StartAsync(stoppingToken).ConfigureAwait(false);

            _logger.LogInformation("SMTP Server stopped.");
        }
Пример #3
0
 protected override Task ExecuteAsync(CancellationToken stoppingToken)
 {
     return(_smtpServer.StartAsync(stoppingToken));
 }
 public Task StartAsync(CancellationToken cancellationToken)
 {
     return(_adaptee.StartAsync(cancellationToken));
 }