Skip to content

Commit

Permalink
FIx email sending errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
prince272 committed Apr 6, 2022
1 parent 8f40237 commit e77a5db
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 29 deletions.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "3.1.404",
"version": "3.1.110",
"rollForward": "latestFeature",
"allowPrerelease": false
}
Expand Down
8 changes: 2 additions & 6 deletions src/Neimart.Core/Settings/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
8 changes: 4 additions & 4 deletions src/Neimart.Web/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public async Task<IActionResult> 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,
Expand Down Expand Up @@ -184,7 +184,7 @@ public async Task<IActionResult> 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,
Expand Down Expand Up @@ -345,7 +345,7 @@ public async Task<IActionResult> 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,
Expand Down Expand Up @@ -460,7 +460,7 @@ public async Task<IActionResult> 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,
Expand Down
4 changes: 2 additions & 2 deletions src/Neimart.Web/Controllers/CompanyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public async Task<IActionResult> 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.");
}
Expand Down
4 changes: 1 addition & 3 deletions src/Neimart.Web/Services/MessageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ public async Task SendEmailAsync<TModel>(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(),
};
}
Expand Down Expand Up @@ -122,7 +121,6 @@ public enum MessageRole
{
Admin,
Info,
Support,
Notification
}
}
5 changes: 1 addition & 4 deletions src/Neimart.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ public void ConfigureServices(IServiceCollection services)
AdminEmail = Configuration.GetValue<string>("Sending:Smtp:Credentials:Admin:Email"),
AdminPassword = Configuration.GetValue<string>("Sending:Smtp:Credentials:Admin:Password"),

SupportEmail = Configuration.GetValue<string>("Sending:Smtp:Credentials:Support:Email"),
SupportPassword = Configuration.GetValue<string>("Sending:Smtp:Credentials:Support:Password"),

InfoEmail = Configuration.GetValue<string>("Sending:Smtp:Credentials:Info:Email"),
InfoPassword = Configuration.GetValue<string>("Sending:Smtp:Credentials:Info:Password"),

Expand Down Expand Up @@ -339,7 +336,7 @@ public void ConfigureServices(IServiceCollection services)
{
options.Server = Configuration.GetValue<string>("Sending:Smtp:Server");
options.Port = Configuration.GetValue<int>("Sending:Smtp:Port");
options.EnableSsl = false;
options.EnableSsl = true;
});
services.AddSmsSender();

Expand Down
2 changes: 1 addition & 1 deletion src/Neimart.Web/Views/Account/AccessDenied.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
<div class="mb-3 text-center">
<div class="mb-3"><i class="fad fa-user-slash fa-5x text-primary"></i></div>
<div>You do not have access to this resource. The most common reason for this error is a mistyped URL. Please <a href="mailto:@(AppSettings.Value.Company.SupportEmail)">contact support</a> to address this problem.</div>
<div>You do not have access to this resource. The most common reason for this error is a mistyped URL. Please <a href="mailto:@(AppSettings.Value.Company.InfoEmail)">contact support</a> to address this problem.</div>
</div>
</div>
</div>
2 changes: 1 addition & 1 deletion src/Neimart.Web/Views/Account/Lockout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</div>
<div class="mb-3 text-center">
<div class="mb-3"><i class="fad fa-user-lock fa-5x text-primary"></i></div>
<div>Your account has been locked for security purposes. Possible cause may be due to too many incorrect password attempts. Please <a href="mailto:@(AppSettings.Value.Company.SupportEmail)">contact support</a> to address this problem.</div>
<div>Your account has been locked for security purposes. Possible cause may be due to too many incorrect password attempts. Please <a href="mailto:@(AppSettings.Value.Company.InfoEmail)">contact support</a> to address this problem.</div>
</div>
<div class="form-group">
<a asp-action="Signin" asp-controller="Account" asp-area="" asp-route-returnUrl="@(Context.Request.Query["returnUrl"])" class="btn btn-default btn-block">Return to sign in</a>
Expand Down
2 changes: 1 addition & 1 deletion src/Neimart.Web/Views/Company/Contact.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>
<div class="pb-4">
<div class="mb-2"><span class="font-weight-semibold">EMAIL</span></div>
<a class="d-block" href="mailto:@(AppSettings.Value.Company.SupportEmail)"><i class="fas fa-envelope text-primary mx-1"></i><span class="theme-text-dark">@(AppSettings.Value.Company.SupportEmail)</span></a>
<a class="d-block" href="mailto:@(AppSettings.Value.Company.InfoEmail)"><i class="fas fa-envelope text-primary mx-1"></i><span class="theme-text-dark">@(AppSettings.Value.Company.InfoEmail)</span></a>
</div>
<div class="pb-4" visible="@(!string.IsNullOrWhiteSpace(AppSettings.Value.Company.Address))">
<div class="mb-2"><span class="font-weight-semibold">ADDRESS</span></div>
Expand Down
8 changes: 2 additions & 6 deletions src/Neimart.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@
},
"Sending": {
"Smtp": {
"Server": "mail.neimart.com",
"Port": "8889",
"Server": "mail5018.site4now.net",
"Port": "465",
"Credentials": {
"Admin": {
"Email": "[email protected]",
"Password": "prince@1234"
},
"Support": {
"Email": "[email protected]",
"Password": "prince@1234"
},
"Info": {
"Email": "[email protected]",
"Password": "prince@1234"
Expand Down

0 comments on commit e77a5db

Please sign in to comment.