From 767b833cc5edb03af4372c806900f90f3b415e9c Mon Sep 17 00:00:00 2001 From: Uncled1023 Date: Wed, 20 Jun 2018 20:01:36 -0700 Subject: [PATCH] Modified HMailService to use common initiator for deleting accounts --- MailService/HMailService.cs | 10 ++++------ Teknik/Areas/User/Utility/UserHelper.cs | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/MailService/HMailService.cs b/MailService/HMailService.cs index cfddf55..18eeb49 100644 --- a/MailService/HMailService.cs +++ b/MailService/HMailService.cs @@ -8,6 +8,7 @@ namespace Teknik.MailService { private readonly hMailServer.Application _App; + private string _Host { get; set; } private string _Username { get; set; } private string _Password { get; set; } private string _Domain { get; set; } @@ -18,8 +19,9 @@ namespace Teknik.MailService private string _CounterPassword { get; set; } private int _CounterPort { get; set; } - public HMailService(string username, string password, string domain, string counterServer, string counterDatabase, string counterUsername, string counterPassword, int counterPort) + public HMailService(string host, string username, string password, string domain, string counterServer, string counterDatabase, string counterUsername, string counterPassword, int counterPort) { + _Host = host; _Username = username; _Password = password; _Domain = domain; @@ -59,11 +61,7 @@ namespace Teknik.MailService public void DeleteAccount(string username) { - var app = new hMailServer.Application(); - app.Connect(); - app.Authenticate(_Username, _Password); - var domain = app.Domains.ItemByName[_Domain]; - var account = domain.Accounts.ItemByAddress[username]; + var account = GetAccount(username); if (account != null) { account.Delete(); diff --git a/Teknik/Areas/User/Utility/UserHelper.cs b/Teknik/Areas/User/Utility/UserHelper.cs index 235b5c2..73f392c 100644 --- a/Teknik/Areas/User/Utility/UserHelper.cs +++ b/Teknik/Areas/User/Utility/UserHelper.cs @@ -877,6 +877,7 @@ If you recieved this email and you did not reset your password, you can ignore t public static IMailService CreateMailService(Config config) { return new HMailService( + config.EmailConfig.MailHost, config.EmailConfig.Username, config.EmailConfig.Password, config.EmailConfig.Domain,