From 9383a2fb09ffb60cfe63683106945bd688affa59 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Wed, 1 Jun 2022 21:13:43 +0200 Subject: feat: Initial commit after clean slate --- src/Services/EmailService.cs | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/Services/EmailService.cs (limited to 'src/Services/EmailService.cs') diff --git a/src/Services/EmailService.cs b/src/Services/EmailService.cs new file mode 100644 index 0000000..d5098e0 --- /dev/null +++ b/src/Services/EmailService.cs @@ -0,0 +1,45 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; + +namespace VSH.Services; + +public class EmailService +{ + private readonly string _sendGridApiKey; + private readonly string _fromAddress; + private readonly string _fromName; + private readonly string _replyToAddress; + private readonly ILogger _logger; + + public EmailService(IConfiguration configuration, ILogger logger) { + _sendGridApiKey = configuration.GetValue("SENDGRID_API_KEY"); + _fromAddress = configuration.GetValue("MAIL_FROM_ADDRESS"); + _replyToAddress = configuration.GetValue("MAIL_REPLY_TO_ADDRESS"); + _fromName = configuration.GetValue("MAIL_FROM_NAME"); + _logger = logger; + } + + public async Task SendEmailAsync( + string subject, + string message, + IEnumerable recipients + ) { + foreach (var recipient in recipients) { + if (!await SendEmailAsync(subject, message, recipient)) { + return false; + } + } + + return true; + } + + public Task SendEmailAsync( + string subject, + string message, + string recipient + ) { + return Task.FromResult(false); + } +} -- cgit v1.3