Files
social-media/backend/src/Socialize.Api/Infrastructure/Emailer/Services/LoggerEmailSender.cs
2026-04-29 20:58:36 -04:00

23 lines
686 B
C#

using Socialize.Api.Infrastructure.Emailer.Contracts;
namespace Socialize.Api.Infrastructure.Emailer.Services;
public class LoggerEmailSender(ILogger<IEmailSender> logger)
: IEmailSender
{
public async Task SendEmailAsync(string email, string subject, string message)
{
try
{
logger.LogInformation("Sending email to {Email} with subject: {Subject}", email, subject);
await Task.Delay(1000);
logger.LogInformation("Email sent successfully to {Email}", email);
}
catch (Exception ex)
{
logger.LogError(ex, "Failed to send email to {Email}", email);
throw;
}
}
}