diff --git a/src/ClientManager.Application/AuthApplication.cs b/src/ClientManager.Application/AuthApplication.cs index fe569e8..72b6983 100644 --- a/src/ClientManager.Application/AuthApplication.cs +++ b/src/ClientManager.Application/AuthApplication.cs @@ -1,4 +1,5 @@ using ClientManager.Application.Mappers; +using ClientManager.Domain.Core.Interfaces.Services; using ClientManager.Domain.Core.Responses; using FluentValidation; @@ -52,6 +53,18 @@ public AuthApplication( await _userService.AddUserAsync(user).ConfigureAwait(false); + _ = Task.Run(async () => + { + try + { + await _emailService.SendWelcomeEmailAsync(user.Email, user.Username).ConfigureAwait(false); + } + catch + { + // fire-and-forget: email failure should not block registration + } + }); + var token = _tokenService.GenerateToken(user.Id, user.Username, user.Email, user.Role); var refreshToken = _tokenService.GenerateRefreshToken(); _refreshTokens[refreshToken] = user.Id; diff --git a/src/ClientManager.Infrastructure/Services/SmtpEmailService.cs b/src/ClientManager.Infrastructure/Services/SmtpEmailService.cs index 1abcf50..3b839d4 100644 --- a/src/ClientManager.Infrastructure/Services/SmtpEmailService.cs +++ b/src/ClientManager.Infrastructure/Services/SmtpEmailService.cs @@ -61,7 +61,7 @@ public async Task SendWelcomeEmailAsync(string email, string name, byte[]? attac public async Task SendWelcomeEmailToUserAsync(string email, string username) { var host = configuration["Smtp:Host"]; - var port = int.Parse(configuration["Smtp:Port"] ?? "587"); + var port = int.Parse(configuration["Smtp:Port"] ?? "587", CultureInfo.InvariantCulture); var username2 = configuration["Smtp:Username"]; var password = configuration["Smtp:Password"]; var fromEmail = configuration["Smtp:FromEmail"] ?? "no-reply@clientmanager.com";