diff --git a/src/ClientManager.Infrastructure/Services/ResendEmailService.cs b/src/ClientManager.Infrastructure/Services/ResendEmailService.cs index 6e66ef4..1130cfe 100644 --- a/src/ClientManager.Infrastructure/Services/ResendEmailService.cs +++ b/src/ClientManager.Infrastructure/Services/ResendEmailService.cs @@ -71,4 +71,68 @@ public async Task SendWelcomeEmailAsync(string email, string name, byte[]? attac logger.LogError(ex, "Exception while sending email to {Email} via Resend", email); } } + + public async Task SendWelcomeEmailToUserAsync(string email, string username) + { + var apiKey = configuration["Resend:ApiKey"]; + var fromEmail = configuration["Resend:FromEmail"] ?? "onboarding@resend.dev"; + var fromName = configuration["Resend:FromName"] ?? "ClientManager"; + + if (string.IsNullOrEmpty(apiKey)) + { + logger.LogWarning("Resend API key not configured. Skipping welcome email to {Email}", email); + return; + } + + try + { + using var client = new SmtpClient("smtp.resend.com", 465) + { + Credentials = new NetworkCredential("resend", apiKey), + EnableSsl = true + }; + + var htmlContent = $@" +
Hello {username},
+Congratulations! Your registration at ClientManager has been completed successfully.
+You now have full access to our client and document management platform.
+Next steps:
+If you have any questions, our team is ready to help.
+Best regards,
ClientManager Team
© {DateTime.UtcNow.Year} ClientManager. All rights reserved.
+