Files
social-media/backend/Infrastructure/Emailer/Services/LoggerEmailSender.cs
2025-06-13 02:22:35 -04:00

23 lines
672 B
C#

using Hutopy.Infrastructure.Emailer.Contracts;
namespace Hutopy.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;
}
}
}