using System.Net.Mail; using Microsoft.Extensions.Options; namespace plushealthtech.Mail { /// /// Sends outbound email through the configured SMTP server (MailPit in local /// development). No authentication is used. /// public class MailSender { private readonly SmtpOptions _options; private readonly ILogger _logger; public MailSender(IOptions options, ILogger logger) { _options = options.Value; _logger = logger; } public async Task SendAsync(string subject, string body) { using var client = new SmtpClient(_options.Host, _options.Port) { EnableSsl = false }; var message = new MailMessage(_options.From, _options.To) { Subject = subject, Body = body, IsBodyHtml = false }; await client.SendMailAsync(message); _logger.LogInformation("Mail sent to {To} (subject: {Subject})", _options.To, subject); } } }