From e77a5dbafd34871f0a1793a2705e4e56f7b8c549 Mon Sep 17 00:00:00 2001 From: Prince Owusu Date: Wed, 6 Apr 2022 12:50:26 +0000 Subject: [PATCH] FIx email sending errors. --- global.json | 2 +- src/Neimart.Core/Settings/AppSettings.cs | 8 ++------ src/Neimart.Web/Controllers/AccountController.cs | 8 ++++---- src/Neimart.Web/Controllers/CompanyController.cs | 4 ++-- src/Neimart.Web/Services/MessageService.cs | 4 +--- src/Neimart.Web/Startup.cs | 5 +---- src/Neimart.Web/Views/Account/AccessDenied.cshtml | 2 +- src/Neimart.Web/Views/Account/Lockout.cshtml | 2 +- src/Neimart.Web/Views/Company/Contact.cshtml | 2 +- src/Neimart.Web/appsettings.json | 8 ++------ 10 files changed, 16 insertions(+), 29 deletions(-) diff --git a/global.json b/global.json index 40867ed..422b6a1 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "3.1.404", + "version": "3.1.110", "rollForward": "latestFeature", "allowPrerelease": false } diff --git a/src/Neimart.Core/Settings/AppSettings.cs b/src/Neimart.Core/Settings/AppSettings.cs index 6214c18..2cba186 100644 --- a/src/Neimart.Core/Settings/AppSettings.cs +++ b/src/Neimart.Core/Settings/AppSettings.cs @@ -202,18 +202,14 @@ public class CompanyInfo public string AdminPassword { get; set; } - public string SupportEmail { get; set; } + public string NotificationEmail { get; set; } - public string SupportPassword { get; set; } + public string NotificationPassword { get; set; } public string InfoEmail { get; set; } public string InfoPassword { get; set; } - public string NotificationEmail { get; set; } - - public string NotificationPassword { get; set; } - public string PhoneNumber { get; set; } public string PhoneNumber2 { get; set; } diff --git a/src/Neimart.Web/Controllers/AccountController.cs b/src/Neimart.Web/Controllers/AccountController.cs index 4dfd1bb..9345ad8 100644 --- a/src/Neimart.Web/Controllers/AccountController.cs +++ b/src/Neimart.Web/Controllers/AccountController.cs @@ -107,7 +107,7 @@ public async Task Signup(SignUpModel model, string storeName, str var link = Url.Action(nameof(VerifyEmail), "Account", new { userId = member.Id, token, returnUrl }, protocol: Request.Scheme); await _messageService.SendEmailAsync( - messageRole: MessageRole.Support, + messageRole: MessageRole.Notification, messageType: MessageType.VerifyEmail, messageDisplay: "Neimart Support", email: member.Email, @@ -184,7 +184,7 @@ public async Task Signin(SignInModel model, string returnUrl) var link = Url.Action(nameof(VerifyEmail), "Account", new { userId = member.Id, token, returnUrl }, protocol: Request.Scheme); await _messageService.SendEmailAsync( - messageRole: MessageRole.Support, + messageRole: MessageRole.Notification, messageType: MessageType.VerifyEmail, messageDisplay: "Neimart Support", email: member.Email, @@ -345,7 +345,7 @@ public async Task ForgotPassword(ForgotPasswordModel model, strin var link = Url.Action(nameof(ResetPassword), "Account", new { token, email }, protocol: Request.Scheme); await _messageService.SendEmailAsync( - messageRole: MessageRole.Support, + messageRole: MessageRole.Notification, messageType: MessageType.ResetPassword, messageDisplay: "Neimart Support", email: email, @@ -460,7 +460,7 @@ public async Task ChangeEmail(ChangeEmailModel model, string retu var link = Url.Action(nameof(ChangeEmailCallback), "Account", new { token, userId, email, returnUrl }, protocol: Request.Scheme); await _messageService.SendEmailAsync( - messageRole: MessageRole.Support, + messageRole: MessageRole.Notification, messageType: MessageType.ChangeEmail, messageDisplay: "Neimart Support", email: email, diff --git a/src/Neimart.Web/Controllers/CompanyController.cs b/src/Neimart.Web/Controllers/CompanyController.cs index 76f230e..5bed1f4 100644 --- a/src/Neimart.Web/Controllers/CompanyController.cs +++ b/src/Neimart.Web/Controllers/CompanyController.cs @@ -87,10 +87,10 @@ public async Task Contact(ContactModel model) if (ModelState.IsValid) { await _messageService.SendEmailAsync( - messageRole: MessageRole.Support, + messageRole: MessageRole.Info, messageType: MessageType.CompanyContact, messageDisplay: "Neimart Support", - email: _appSettings.Company.SupportEmail, model); + email: _appSettings.Company.InfoEmail, model); TempData.AddAlert(AlertMode.Alert, AlertType.Success, "Your message has been sent. We'll contact you shortly."); } diff --git a/src/Neimart.Web/Services/MessageService.cs b/src/Neimart.Web/Services/MessageService.cs index 3938bca..1b28ee0 100644 --- a/src/Neimart.Web/Services/MessageService.cs +++ b/src/Neimart.Web/Services/MessageService.cs @@ -60,9 +60,8 @@ public async Task SendEmailAsync(MessageRole messageRole, MessageType me return role switch { MessageRole.Admin => (_appSettings.Value.Company.AdminEmail, _appSettings.Value.Company.AdminPassword), - MessageRole.Support => (_appSettings.Value.Company.SupportEmail, _appSettings.Value.Company.SupportPassword), + MessageRole.Notification => (_appSettings.Value.Company.NotificationEmail, _appSettings.Value.Company.NotificationEmail), MessageRole.Info => (_appSettings.Value.Company.InfoEmail, _appSettings.Value.Company.InfoPassword), - MessageRole.Notification => (_appSettings.Value.Company.NotificationEmail, _appSettings.Value.Company.NotificationPassword), _ => throw new InvalidOperationException(), }; } @@ -122,7 +121,6 @@ public enum MessageRole { Admin, Info, - Support, Notification } } diff --git a/src/Neimart.Web/Startup.cs b/src/Neimart.Web/Startup.cs index 96134cb..5b996ff 100644 --- a/src/Neimart.Web/Startup.cs +++ b/src/Neimart.Web/Startup.cs @@ -76,9 +76,6 @@ public void ConfigureServices(IServiceCollection services) AdminEmail = Configuration.GetValue("Sending:Smtp:Credentials:Admin:Email"), AdminPassword = Configuration.GetValue("Sending:Smtp:Credentials:Admin:Password"), - SupportEmail = Configuration.GetValue("Sending:Smtp:Credentials:Support:Email"), - SupportPassword = Configuration.GetValue("Sending:Smtp:Credentials:Support:Password"), - InfoEmail = Configuration.GetValue("Sending:Smtp:Credentials:Info:Email"), InfoPassword = Configuration.GetValue("Sending:Smtp:Credentials:Info:Password"), @@ -339,7 +336,7 @@ public void ConfigureServices(IServiceCollection services) { options.Server = Configuration.GetValue("Sending:Smtp:Server"); options.Port = Configuration.GetValue("Sending:Smtp:Port"); - options.EnableSsl = false; + options.EnableSsl = true; }); services.AddSmsSender(); diff --git a/src/Neimart.Web/Views/Account/AccessDenied.cshtml b/src/Neimart.Web/Views/Account/AccessDenied.cshtml index c970e15..0976ba6 100644 --- a/src/Neimart.Web/Views/Account/AccessDenied.cshtml +++ b/src/Neimart.Web/Views/Account/AccessDenied.cshtml @@ -9,7 +9,7 @@
-
You do not have access to this resource. The most common reason for this error is a mistyped URL. Please contact support to address this problem.
+
You do not have access to this resource. The most common reason for this error is a mistyped URL. Please contact support to address this problem.
\ No newline at end of file diff --git a/src/Neimart.Web/Views/Account/Lockout.cshtml b/src/Neimart.Web/Views/Account/Lockout.cshtml index 6e474ea..38e628c 100644 --- a/src/Neimart.Web/Views/Account/Lockout.cshtml +++ b/src/Neimart.Web/Views/Account/Lockout.cshtml @@ -9,7 +9,7 @@
-
Your account has been locked for security purposes. Possible cause may be due to too many incorrect password attempts. Please contact support to address this problem.
+
Your account has been locked for security purposes. Possible cause may be due to too many incorrect password attempts. Please contact support to address this problem.
Return to sign in diff --git a/src/Neimart.Web/Views/Company/Contact.cshtml b/src/Neimart.Web/Views/Company/Contact.cshtml index 98ac787..3ffe08c 100644 --- a/src/Neimart.Web/Views/Company/Contact.cshtml +++ b/src/Neimart.Web/Views/Company/Contact.cshtml @@ -24,7 +24,7 @@
ADDRESS
diff --git a/src/Neimart.Web/appsettings.json b/src/Neimart.Web/appsettings.json index 3eb227a..e8874e9 100644 --- a/src/Neimart.Web/appsettings.json +++ b/src/Neimart.Web/appsettings.json @@ -18,17 +18,13 @@ }, "Sending": { "Smtp": { - "Server": "mail.neimart.com", - "Port": "8889", + "Server": "mail5018.site4now.net", + "Port": "465", "Credentials": { "Admin": { "Email": "admin@neimart.com", "Password": "prince@1234" }, - "Support": { - "Email": "support@neimart.com", - "Password": "prince@1234" - }, "Info": { "Email": "info@neimart.com", "Password": "prince@1234"