From b7e39b59fd0fc7b5610ebff29035bf622079e0d8 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Wed, 5 Oct 2022 20:45:21 +0800 Subject: refactor: Change file structure --- server/src/Services/MailService.cs | 49 -------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 server/src/Services/MailService.cs (limited to 'server/src/Services/MailService.cs') diff --git a/server/src/Services/MailService.cs b/server/src/Services/MailService.cs deleted file mode 100644 index c08cb84..0000000 --- a/server/src/Services/MailService.cs +++ /dev/null @@ -1,49 +0,0 @@ -namespace IOL.GreatOffice.Api.Services; - -public class MailService -{ - private readonly ILogger _logger; - private static string _emailHost; - private static int _emailPort; - private static string _emailUser; - private static string _emailPassword; - - public MailService(VaultService vaultService, ILogger logger) { - var configuration = vaultService.GetCurrentAppConfiguration(); - _logger = logger; - _emailHost = configuration.SMTP_HOST; - _emailPort = Convert.ToInt32(configuration.SMTP_PORT); - _emailUser = configuration.SMTP_USER; - _emailPassword = configuration.SMTP_PASSWORD; - } - - /// - /// Send an email. - /// - /// - public void SendMail(MailMessage message) { - using var smtpClient = new SmtpClient { - Host = _emailHost, - EnableSsl = _emailPort == 587, - Port = _emailPort, - Credentials = new NetworkCredential { - UserName = _emailUser, - Password = _emailPassword, - } - }; - var configurationString = JsonSerializer.Serialize(new { - smtpClient.Host, - smtpClient.EnableSsl, - smtpClient.Port, - UserName = _emailUser.HasValue() ? "**REDACTED**" : "**MISSING**", - Password = _emailPassword.HasValue() ? "**REDACTED**" : "**MISSING**", - }, - new JsonSerializerOptions { - WriteIndented = true - }); - - _logger.LogDebug("SmtpClient was instansiated with the following configuration\n" + configurationString); - - smtpClient.Send(message); - } -} \ No newline at end of file -- cgit v1.3