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"); } }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { _logger.LogInformation("SMTP Server started."); await _smtpServer.StartAsync(stoppingToken).ConfigureAwait(false); _logger.LogInformation("SMTP Server stopped."); }
protected override Task ExecuteAsync(CancellationToken stoppingToken) { return(_smtpServer.StartAsync(stoppingToken)); }
public Task StartAsync(CancellationToken cancellationToken) { return(_adaptee.StartAsync(cancellationToken)); }