Skip to content

Commit

Permalink
Log out configured SMTP settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Layoric committed Jan 5, 2024
1 parent a0145bc commit 0b4502e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions BlazorDiffusion/Configure.Smtp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ public void Configure(IWebHostBuilder builder) => builder
.ConfigureAppHost(appHost => {
var mqService = appHost.Resolve<IMessageService>();
mqService.RegisterHandler<SendEmail>(appHost.ExecuteMessage);
// Check if SMTP is configured
var smtpConfig = appHost.TryResolve<SmtpConfig>();
var log = appHost.GetApplicationServices().GetRequiredService<ILogger<ConfigureSmtp>>();
// Log if missing
if (smtpConfig is null)
{
log.LogWarning("SMTP is not configured, please configure SMTP to enable sending emails");
}
else
{
log.LogWarning("SMTP is configured with <{SmtpConfigFromEmail}> {SmtpConfigFromName}", smtpConfig.FromEmail, smtpConfig.FromName);
}
});
}
}

0 comments on commit 0b4502e

Please sign in to comment.