diff --git a/mailServer/mailserverManager.py b/mailServer/mailserverManager.py index b5e387627..187fbbe74 100755 --- a/mailServer/mailserverManager.py +++ b/mailServer/mailserverManager.py @@ -226,6 +226,38 @@ class MailServerManager: json_data = json.dumps(data_ret) return HttpResponse(json_data) + def fixMailSSL(self): + try: + + userID = self.request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + data = json.loads(self.request.body) + selectedDomain = data['selectedDomain'] + + admin = Administrator.objects.get(pk=userID) + + if ACLManager.checkOwnership(selectedDomain, admin, currentACL) == 1: + pass + else: + return ACLManager.loadErrorJson('status', 0) + + website = Websites.objects.get(domain=selectedDomain) + + execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" + execPath = '%s setupAutoDiscover --virtualHostName %s --websiteOwner %s' % (execPath, selectedDomain, website.admin.userName) + + ProcessUtilities.executioner(execPath) + + data_ret = {'status': 1, 'error_message': "None"} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + + except BaseException as msg: + data_ret = {'status': 0, 'error_message': str(msg)} + json_data = json.dumps(data_ret) + return HttpResponse(json_data) + def emailForwarding(self): try: userID = self.request.session['userID'] @@ -476,6 +508,19 @@ class MailServerManager: except: raise BaseException('No emails exist for this domain.') + postfixMapPath = '/etc/postfix/vmail_ssl.map' + + if os.path.exists(postfixMapPath): + + postfixMapData = open(postfixMapPath, 'r').read() + + if postfixMapData.find(selectedDomain) == -1: + mailConfigured = 0 + else: + mailConfigured = 1 + else: + mailConfigured = 0 + records = emailDomain.eusers_set.all() json_data = "[" @@ -492,7 +537,7 @@ class MailServerManager: json_data = json_data + ',' + json.dumps(dic) json_data = json_data + ']' - final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'error_message': "None", "data": json_data}) + final_json = json.dumps({'status': 1, 'fetchStatus': 1, 'mailConfigured': mailConfigured, 'error_message': "None", "data": json_data}) return HttpResponse(final_json) except BaseException as msg: diff --git a/mailServer/static/mailServer/mailServer.js b/mailServer/static/mailServer/mailServer.js index 3bf1db1c3..c33087815 100755 --- a/mailServer/static/mailServer/mailServer.js +++ b/mailServer/static/mailServer/mailServer.js @@ -1124,6 +1124,7 @@ app.controller('listEmails', function ($scope, $http) { $scope.cyberpanelLoading = true; $scope.emailsAccounts = true; + $scope.mailConfigured = 1; $scope.populateCurrentRecords = function () { $scope.cyberpanelLoading = false; @@ -1151,6 +1152,8 @@ app.controller('listEmails', function ($scope, $http) { if (response.data.status === 1) { $scope.emailsAccounts = false; $scope.records = JSON.parse(response.data.data); + $scope.mailConfigured = response.data.mailConfigured; + new PNotify({ title: 'Success!', text: 'Emails Successfully Fetched.', @@ -1229,6 +1232,55 @@ app.controller('listEmails', function ($scope, $http) { } + }; + + $scope.fixMailSSL = function (email) { + + $scope.cyberpanelLoading = false; + + var url = "/email/fixMailSSL"; + + var data = { + selectedDomain: $scope.selectedDomain, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + function ListInitialDatas(response) { + if (response.data.status === 1) { + $scope.populateCurrentRecords(); + new PNotify({ + title: 'Success!', + text: 'Configurations applied successfully.', + type: 'success' + }); + + } else { + new PNotify({ + title: 'Error!', + text: response.data.error_message, + type: 'error' + }); + + } + + } + + function cantLoadInitialDatas(response) { + new PNotify({ + title: 'Error!', + text: 'Could not connect to server, please refresh this page.', + type: 'error' + }); + } + + }; $scope.changePasswordInitial = function (email) { diff --git a/mailServer/templates/mailServer/listEmails.html b/mailServer/templates/mailServer/listEmails.html index 955cdf4f8..4ed7781ff 100755 --- a/mailServer/templates/mailServer/listEmails.html +++ b/mailServer/templates/mailServer/listEmails.html @@ -56,6 +56,15 @@
{% trans "SSL for email is not configured properly, you may get Self-Signed error on mail clients such as Outlook and Thunderbird. More details " %}here.
+