From 55675455b7ed9c1a5be46b320ea243dcc73b1c41 Mon Sep 17 00:00:00 2001 From: Zarak Khan Date: Wed, 24 Jan 2024 11:35:30 +0500 Subject: [PATCH] Email App --- .../templates/baseTemplate/newBase.html | 10 +- mailServer/mailserverManager.py | 65 +- mailServer/static/mailServer/mailServerV2.js | 1096 +++++++++++++++++ .../mailServer/changeEmailPasswordV2.html | 118 ++ .../mailServer/deleteEmailAccountV2.html | 94 ++ .../templates/mailServer/dkimManagerV2.html | 152 +++ .../mailServer/emailForwardingV2.html | 141 +++ .../templates/mailServer/listEmailsV2.html | 386 +++--- mailServer/urls.py | 10 +- mailServer/views.py | 32 + upgrade.sh | 2 +- 11 files changed, 1904 insertions(+), 202 deletions(-) create mode 100644 mailServer/templates/mailServer/changeEmailPasswordV2.html create mode 100644 mailServer/templates/mailServer/deleteEmailAccountV2.html create mode 100644 mailServer/templates/mailServer/dkimManagerV2.html create mode 100644 mailServer/templates/mailServer/emailForwardingV2.html diff --git a/baseTemplate/templates/baseTemplate/newBase.html b/baseTemplate/templates/baseTemplate/newBase.html index fa470ab18..77f816a59 100644 --- a/baseTemplate/templates/baseTemplate/newBase.html +++ b/baseTemplate/templates/baseTemplate/newBase.html @@ -658,22 +658,22 @@ List Emails
  • - • Delete Email
  • - • Email Forwarding
  • - • Change Password
  • - • DKIM Manager
  • @@ -683,7 +683,7 @@ Email Debugger
  • - • Access Webmail
  • diff --git a/mailServer/mailserverManager.py b/mailServer/mailserverManager.py index 26e65f00d..1b063867e 100755 --- a/mailServer/mailserverManager.py +++ b/mailServer/mailserverManager.py @@ -183,6 +183,22 @@ class MailServerManager(multi.Thread): {'websiteList': websitesName, "status": 1}, 'deleteEmail') return proc.render() + def deleteEmailAccountV2(self): + userID = self.request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if not os.path.exists('/home/cyberpanel/postfix'): + proc = httpProc(self.request, 'mailServer/deleteEmailAccount.html', + {"status": 0}, 'deleteEmail') + return proc.render() + + websitesName = ACLManager.findAllSites(currentACL, userID) + websitesName = websitesName + ACLManager.findChildDomains(websitesName) + + proc = httpProc(self.request, 'mailServer/deleteEmailAccountV2.html', + {'websiteList': websitesName, "status": 1}, 'deleteEmail') + return proc.render() + def getEmailsForDomain(self): try: userID = self.request.session['userID'] @@ -297,7 +313,7 @@ class MailServerManager(multi.Thread): execPath = "/usr/local/CyberCP/bin/python " + virtualHostUtilities.cyberPanel + "/plogical/virtualHostUtilities.py" execPath = '%s setupAutoDiscover --virtualHostName %s --websiteOwner %s' % ( - execPath, selectedDomain, website.admin.userName) + execPath, selectedDomain, website.admin.userName) ProcessUtilities.executioner(execPath) @@ -326,6 +342,22 @@ class MailServerManager(multi.Thread): {'websiteList': websitesName, "status": 1}, 'emailForwarding') return proc.render() + def emailForwardingV2(self): + userID = self.request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if not os.path.exists('/home/cyberpanel/postfix'): + proc = httpProc(self.request, 'mailServer/emailForwardingV2.html', + {"status": 0}, 'emailForwarding') + return proc.render() + + websitesName = ACLManager.findAllSites(currentACL, userID) + websitesName = websitesName + ACLManager.findChildDomains(websitesName) + + proc = httpProc(self.request, 'mailServer/emailForwardingV2.html', + {'websiteList': websitesName, "status": 1}, 'emailForwarding') + return proc.render() + def fetchCurrentForwardings(self): try: @@ -511,7 +543,7 @@ class MailServerManager(multi.Thread): pipeowner = externalApp ## Add Filter pipe to postfix /etc/postfix/master.cf filterpipe = '%spipe unix - n n - - pipe flags=Rq user=%s argv=%s -f $(sender) -- $(recipient)' % ( - sourceusername, pipeowner, destination) + sourceusername, pipeowner, destination) command = "echo '" + filterpipe + "' >> /etc/postfix/master.cf" ProcessUtilities.executioner(command) ## Add Check Recipient Hash to postfix /etc/postfix/main.cf @@ -613,6 +645,22 @@ class MailServerManager(multi.Thread): {'websiteList': websitesName, "status": 1}, 'changeEmailPassword') return proc.render() + def changeEmailAccountPasswordV2(self): + userID = self.request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + if not os.path.exists('/home/cyberpanel/postfix'): + proc = httpProc(self.request, 'mailServer/changeEmailPasswordV2.html', + {"status": 0}, 'changeEmailPassword') + return proc.render() + + websitesName = ACLManager.findAllSites(currentACL, userID) + websitesName = websitesName + ACLManager.findChildDomains(websitesName) + + proc = httpProc(self.request, 'mailServer/changeEmailPasswordV2.html', + {'websiteList': websitesName, "status": 1}, 'changeEmailPassword') + return proc.render() + def submitPasswordChange(self): try: userID = self.request.session['userID'] @@ -674,6 +722,19 @@ class MailServerManager(multi.Thread): {'websiteList': websitesName, 'openDKIMInstalled': openDKIMInstalled}, 'dkimManager') return proc.render() + def dkimManagerV2(self): + userID = self.request.session['userID'] + currentACL = ACLManager.loadedACL(userID) + + openDKIMInstalled = 1 + + websitesName = ACLManager.findAllSites(currentACL, userID) + websitesName = websitesName + ACLManager.findChildDomains(websitesName) + + proc = httpProc(self.request, 'mailServer/dkimManagerV2.html', + {'websiteList': websitesName, 'openDKIMInstalled': openDKIMInstalled}, 'dkimManager') + return proc.render() + def fetchDKIMKeys(self): try: userID = self.request.session['userID'] diff --git a/mailServer/static/mailServer/mailServerV2.js b/mailServer/static/mailServer/mailServerV2.js index d76af33a9..0115a1923 100644 --- a/mailServer/static/mailServer/mailServerV2.js +++ b/mailServer/static/mailServer/mailServerV2.js @@ -334,4 +334,1100 @@ newapp.controller('listEmailsV2', function ($scope, $http) { }; +}); +newapp.controller('deleteEmailAccountV2', function ($scope, $http) { + + $scope.emailDetails = true; + $scope.emailLoading = true; + $scope.canNotDelete = true; + $scope.successfullyDeleted = true; + $scope.couldNotConnect = true; + $scope.emailDetailsFinal = true; + $scope.noEmails = true; + + $scope.showEmailDetails = function () { + + $scope.emailDetails = true; + $scope.emailLoading = false; + $scope.canNotDelete = true; + $scope.successfullyDeleted = true; + $scope.couldNotConnect = true; + $scope.emailDetailsFinal = true; + $scope.noEmails = true; + + + var url = "/email/getEmailsForDomain"; + + var domain = $scope.emailDomain; + + + var data = { + domain: domain, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.fetchStatus == 1) { + + $scope.emails = JSON.parse(response.data.data); + + + $scope.emailDetails = false; + $scope.emailLoading = true; + $scope.canNotDelete = true; + $scope.successfullyDeleted = true; + $scope.couldNotConnect = true; + $scope.emailDetailsFinal = true; + $scope.noEmails = true; + + + } else { + $scope.emailDetails = true; + $scope.emailLoading = true; + $scope.canNotDelete = true; + $scope.successfullyDeleted = true; + $scope.couldNotConnect = true; + $scope.emailDetailsFinal = true; + $scope.noEmails = false; + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.emailDetails = true; + $scope.emailLoading = true; + $scope.canNotDelete = true; + $scope.successfullyDeleted = true; + $scope.couldNotConnect = false; + $scope.emailDetailsFinal = true; + $scope.noEmails = true; + + + } + + + }; + + + $scope.deleteEmailAccountFinal = function () { + + $scope.emailLoading = false; + + + var url = "/email/submitEmailDeletion"; + + var email = $scope.selectedEmail; + + + var data = { + email: email, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.deleteEmailStatus === 1) { + + + $scope.emailDetails = true; + $scope.emailLoading = true; + $scope.canNotDelete = true; + $scope.successfullyDeleted = false; + $scope.couldNotConnect = true; + $scope.emailDetailsFinal = true; + $scope.noEmails = true; + + $scope.deletedID = email; + + } else { + $scope.emailDetails = true; + $scope.emailLoading = true; + $scope.canNotDelete = false; + $scope.successfullyDeleted = true; + $scope.couldNotConnect = true; + $scope.emailDetailsFinal = true; + $scope.noEmails = true; + + $scope.errorMessage = response.data.error_message; + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.emailDetails = true; + $scope.emailLoading = true; + $scope.canNotDelete = true; + $scope.successfullyDeleted = true; + $scope.couldNotConnect = false; + $scope.emailDetailsFinal = true; + $scope.noEmails = true; + + + } + + + }; + + + $scope.deleteEmailAccount = function () { + + var domain = $scope.selectedEmail; + + if (domain.length > 0) { + $scope.emailDetailsFinal = false; + } + + }; + +}); +newapp.controller('createEmailAccountV2', function ($scope, $http) { + + $scope.emailDetails = true; + $scope.emailLoading = true; + $scope.canNotCreate = true; + $scope.successfullyCreated = true; + $scope.couldNotConnect = true; + + $scope.showEmailDetails = function () { + + $scope.emailDetails = false; + $scope.emailLoading = true; + $scope.canNotCreate = true; + $scope.successfullyCreated = true; + $scope.couldNotConnect = true; + + + $scope.selectedDomain = $scope.emailDomain; + + + }; + + $scope.createEmailAccount = function () { + + $scope.emailDetails = false; + $scope.emailLoading = false; + $scope.canNotCreate = true; + $scope.successfullyCreated = true; + $scope.couldNotConnect = true; + + + var url = "/email/submitEmailCreation"; + + var domain = $scope.emailDomain; + var username = $scope.emailUsername; + var password = $scope.emailPassword; + + + var data = { + domain: domain, + username: username, + passwordByPass: password, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.createEmailStatus === 1) { + + $scope.emailDetails = false; + $scope.emailLoading = true; + $scope.canNotCreate = true; + $scope.successfullyCreated = false; + $scope.couldNotConnect = true; + + $scope.createdID = username + "@" + domain; + + + } else { + $scope.emailDetails = false; + $scope.emailLoading = true; + $scope.canNotCreate = false; + $scope.successfullyCreated = true; + $scope.couldNotConnect = true; + + $scope.errorMessage = response.data.error_message; + + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.emailDetails = false; + $scope.emailLoading = true; + $scope.canNotCreate = true; + $scope.successfullyCreated = true; + $scope.couldNotConnect = false; + + + } + + + }; + + $scope.hideFewDetails = function () { + + $scope.successfullyCreated = true; + + }; + + $scope.generatedPasswordView = true; + + $scope.generatePassword = function () { + $scope.generatedPasswordView = false; + $scope.emailPassword = randomPassword(16); + }; + + $scope.usePassword = function () { + $scope.generatedPasswordView = true; + }; + +}); +newapp.controller('changeEmailPasswordV2', function ($scope, $http) { + + $scope.emailLoading = true; + $scope.emailDetails = true; + $scope.canNotChangePassword = true; + $scope.passwordChanged = true; + $scope.couldNotConnect = true; + $scope.noEmails = true; + + $scope.showEmailDetails = function () { + + $scope.emailLoading = false; + $scope.emailDetails = true; + $scope.canNotChangePassword = true; + $scope.passwordChanged = true; + $scope.couldNotConnect = true; + $scope.noEmails = true; + + + var url = "/email/getEmailsForDomain"; + + var domain = $scope.emailDomain; + + + var data = { + domain: domain, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.fetchStatus == 1) { + + $scope.emails = JSON.parse(response.data.data); + + + $scope.emailLoading = true; + $scope.emailDetails = false; + $scope.canNotChangePassword = true; + $scope.passwordChanged = true; + $scope.couldNotConnect = true; + $scope.noEmails = true; + + + } else { + $scope.emailLoading = true; + $scope.emailDetails = true; + $scope.canNotChangePassword = true; + $scope.passwordChanged = true; + $scope.couldNotConnect = true; + $scope.noEmails = false; + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.emailLoading = true; + $scope.emailDetails = true; + $scope.canNotChangePassword = true; + $scope.passwordChanged = true; + $scope.couldNotConnect = false; + $scope.noEmails = true; + + + } + + }; + + $scope.changePassword = function () { + + $scope.emailLoading = false; + + + var url = "/email/submitPasswordChange"; + + var email = $scope.selectedEmail; + var password = $scope.emailPassword; + var domain = $scope.emailDomain; + + + var data = { + domain: domain, + email: email, + passwordByPass: password, + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.passChangeStatus == 1) { + + + $scope.emailLoading = true; + $scope.emailDetails = true; + $scope.canNotChangePassword = true; + $scope.passwordChanged = false; + $scope.couldNotConnect = true; + $scope.noEmails = true; + + $scope.passEmail = email; + + } else { + $scope.emailLoading = true; + $scope.emailDetails = false; + $scope.canNotChangePassword = false; + $scope.passwordChanged = true; + $scope.couldNotConnect = true; + $scope.noEmails = true; + + + $scope.errorMessage = response.data.error_message; + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.emailLoading = true; + $scope.emailDetails = false; + $scope.canNotChangePassword = true; + $scope.passwordChanged = true; + $scope.couldNotConnect = false; + $scope.noEmails = true; + + + } + + + }; + + $scope.deleteEmailAccount = function () { + + var domain = $scope.selectedEmail; + + if (domain.length > 0) { + $scope.emailDetailsFinal = false; + } + + }; + + /// + + $scope.generatedPasswordView = true; + + $scope.generatePassword = function () { + $scope.generatedPasswordView = false; + $scope.emailPassword = randomPassword(16); + }; + + $scope.usePassword = function () { + $scope.generatedPasswordView = true; + }; + + +}); +newapp.controller('dkimManagerV2', function ($scope, $http, $timeout, $window) { + + + $scope.manageDKIMLoading = true; + $scope.dkimError = true; + $scope.dkimSuccess = true; + $scope.couldNotConnect = true; + $scope.domainRecords = true; + $scope.noKeysAvailable = true; + + + $scope.fetchKeys = function () { + + $scope.manageDKIMLoading = false; + $scope.dkimError = true; + $scope.dkimSuccess = true; + $scope.couldNotConnect = true; + $scope.domainRecords = true; + $scope.noKeysAvailable = true; + + + url = "/email/fetchDKIMKeys"; + + var data = { + domainName: $scope.domainName + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.fetchStatus === 1) { + + if (response.data.keysAvailable === 1) { + + $scope.manageDKIMLoading = true; + $scope.dkimError = true; + $scope.dkimSuccess = false; + $scope.couldNotConnect = true; + $scope.domainRecords = false; + $scope.noKeysAvailable = true; + + $scope.privateKey = response.data.privateKey; + $scope.publicKey = response.data.publicKey; + $scope.dkimSuccessMessage = response.data.dkimSuccessMessage; + + + } else { + $scope.manageDKIMLoading = true; + $scope.dkimError = true; + $scope.dkimSuccess = true; + $scope.couldNotConnect = true; + $scope.domainRecords = true; + $scope.noKeysAvailable = false; + } + + + } else { + $scope.errorMessage = response.data.error_message; + + $scope.manageDKIMLoading = true; + $scope.dkimError = false; + $scope.dkimSuccess = true; + $scope.couldNotConnect = true; + $scope.domainRecords = true; + $scope.noKeysAvailable = true; + } + + } + + function cantLoadInitialDatas(response) { + + $scope.manageDKIMLoading = true; + $scope.dkimError = true; + $scope.dkimSuccess = true; + $scope.couldNotConnect = false; + $scope.domainRecords = true; + $scope.noKeysAvailable = true; + + + } + + }; + + $scope.createDomainDKIMKeys = function () { + + $scope.manageDKIMLoading = false; + $scope.dkimError = true; + $scope.dkimSuccess = true; + $scope.couldNotConnect = true; + $scope.domainRecords = true; + $scope.noKeysAvailable = false; + + url = "/email/generateDKIMKeys"; + + var data = { + domainName: $scope.domainName + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + if (response.data.generateStatus === 1) { + + $scope.manageDKIMLoading = true; + $scope.dkimError = true; + $scope.dkimSuccess = true; + $scope.couldNotConnect = true; + $scope.domainRecords = true; + $scope.noKeysAvailable = true; + + $scope.fetchKeys(); + + + } else { + $scope.errorMessage = response.data.error_message; + + $scope.manageDKIMLoading = true; + $scope.dkimError = false; + $scope.dkimSuccess = true; + $scope.couldNotConnect = true; + $scope.domainRecords = true; + $scope.noKeysAvailable = false; + } + + } + + function cantLoadInitialDatas(response) { + + $scope.manageDKIMLoading = true; + $scope.dkimError = true; + $scope.dkimSuccess = true; + $scope.couldNotConnect = false; + $scope.domainRecords = true; + $scope.noKeysAvailable = true; + + + } + + + }; + + // Installation + + + $scope.openDKIMNotifyBox = true; + $scope.openDKIMError = true; + $scope.couldNotConnect = true; + $scope.openDKIMSuccessfullyInstalled = true; + $scope.openDKIMInstallBox = true; + $scope.manageDKIMLoading = true; + + + $scope.installOpenDKIM = function () { + + $scope.openDKIMNotifyBox = true; + $scope.openDKIMError = true; + $scope.couldNotConnect = true; + $scope.openDKIMSuccessfullyInstalled = true; + $scope.openDKIMInstallBox = true; + $scope.manageDKIMLoading = false; + + url = "/email/installOpenDKIM"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.installOpenDKIM === 1) { + + $scope.openDKIMNotifyBox = true; + $scope.openDKIMError = true; + $scope.couldNotConnect = true; + $scope.openDKIMSuccessfullyInstalled = true; + $scope.openDKIMInstallBox = false; + $scope.manageDKIMLoading = true; + + getRequestStatus(); + + } else { + $scope.errorMessage = response.data.error_message; + + $scope.openDKIMNotifyBox = false; + $scope.openDKIMError = false; + $scope.couldNotConnect = true; + $scope.openDKIMSuccessfullyInstalled = true; + $scope.openDKIMInstallBox = true; + $scope.manageDKIMLoading = true; + } + + } + + function cantLoadInitialDatas(response) { + + $scope.openDKIMNotifyBox = false; + $scope.openDKIMError = true; + $scope.couldNotConnect = false; + $scope.openDKIMSuccessfullyInstalled = true; + $scope.openDKIMInstallBox = true; + $scope.manageDKIMLoading = false; + } + + }; + + + function getRequestStatus() { + + $scope.openDKIMNotifyBox = true; + $scope.openDKIMError = true; + $scope.couldNotConnect = true; + $scope.openDKIMSuccessfullyInstalled = true; + $scope.openDKIMInstallBox = false; + $scope.manageDKIMLoading = false; + + + url = "/email/installStatusOpenDKIM"; + + var data = {}; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.abort === 0) { + $scope.requestData = response.data.requestStatus; + $timeout(getRequestStatus, 1000); + } else { + // Notifications + $timeout.cancel(); + + $scope.openDKIMNotifyBox = false; + $scope.openDKIMError = true; + $scope.couldNotConnect = true; + $scope.openDKIMSuccessfullyInstalled = true; + $scope.openDKIMInstallBox = true; + $scope.manageDKIMLoading = true; + + $scope.requestData = response.data.requestStatus; + + if (response.data.installed === 0) { + $scope.openDKIMError = false; + $scope.errorMessage = response.data.error_message; + } else { + $scope.openDKIMSuccessfullyInstalled = false; + $timeout(function () { + $window.location.reload(); + }, 3000); + } + + } + + } + + function cantLoadInitialDatas(response) { + + $scope.modSecNotifyBox = false; + $scope.modeSecInstallBox = false; + $scope.modsecLoading = true; + $scope.failedToStartInallation = true; + $scope.couldNotConnect = false; + $scope.modSecSuccessfullyInstalled = true; + $scope.installationFailed = true; + + + } + + } + + +}); +newapp.controller('emailForwardingV2', function ($scope, $http) { + + $scope.creationBox = true; + $scope.emailDetails = true; + $scope.forwardLoading = true; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = true; + + + $scope.showEmailDetails = function () { + + $scope.creationBox = true; + $scope.emailDetails = true; + $scope.forwardLoading = false; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = true; + + var url = "/email/getEmailsForDomain"; + + + var data = { + domain: $scope.emailDomain + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.fetchStatus === 1) { + + $scope.emails = JSON.parse(response.data.data); + + $scope.creationBox = true; + $scope.emailDetails = false; + $scope.forwardLoading = true; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = false; + + } else { + $scope.creationBox = true; + $scope.emailDetails = true; + $scope.forwardLoading = true; + $scope.forwardError = false; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = false; + + $scope.errorMessage = response.data.error_message; + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.creationBox = true; + $scope.emailDetails = true; + $scope.forwardLoading = true; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = false; + $scope.notifyBox = false; + + + } + + + }; + + $scope.selectForwardingEmail = function () { + + $scope.creationBox = true; + $scope.emailDetails = false; + $scope.forwardLoading = false; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = true; + $scope.fetchCurrentForwardings(); + }; + + $scope.fetchCurrentForwardings = function () { + + if ($scope.forwardingOption == null || $scope.selectedEmail == null) { + $scope.forwardLoading = true; + return 0; + } + + $scope.creationBox = false; + $scope.emailDetails = false; + $scope.forwardLoading = false; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = true; + + var url = "/email/fetchCurrentForwardings"; + + + var data = { + forwardingOption: $scope.forwardingOption, + emailAddress: $scope.selectedEmail + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.fetchStatus === 1) { + + $scope.records = JSON.parse(response.data.data); + + $scope.creationBox = false; + $scope.emailDetails = false; + $scope.forwardLoading = true; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = true; + + } else { + $scope.creationBox = true; + $scope.emailDetails = true; + $scope.forwardLoading = true; + $scope.forwardError = false; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = false; + + $scope.errorMessage = response.data.error_message; + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.creationBox = true; + $scope.emailDetails = true; + $scope.forwardLoading = true; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = false; + $scope.notifyBox = false; + + + } + + + }; + + $scope.deleteForwarding = function (source, destination) { + + $scope.creationBox = true; + $scope.emailDetails = true; + $scope.forwardLoading = false; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = true; + + var url = "/email/submitForwardDeletion"; + + + var data = { + forwardingOption: $scope.forwardingOption, + destination: destination, + source: source + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.deleteForwardingStatus === 1) { + + $scope.creationBox = false; + $scope.emailDetails = false; + $scope.forwardLoading = true; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = true; + + $scope.fetchCurrentForwardings(); + + } else { + $scope.creationBox = false; + $scope.emailDetails = false; + $scope.forwardLoading = true; + $scope.forwardError = false; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = false; + + $scope.errorMessage = response.data.error_message; + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.creationBox = true; + $scope.emailDetails = true; + $scope.forwardLoading = true; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = false; + $scope.notifyBox = false; + + + } + + + }; + + $scope.forwardEmail = function () { + + $scope.creationBox = false; + $scope.emailDetails = false; + $scope.forwardLoading = false; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = true; + + var url = "/email/submitEmailForwardingCreation"; + + + var data = { + forwardingOption: $scope.forwardingOption, + source: $scope.selectedEmail, + destination: $scope.destinationEmail + }; + + var config = { + headers: { + 'X-CSRFToken': getCookie('csrftoken') + } + }; + + $http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas); + + + function ListInitialDatas(response) { + + + if (response.data.createStatus === 1) { + + $scope.creationBox = false; + $scope.emailDetails = false; + $scope.forwardLoading = true; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = true; + + $scope.fetchCurrentForwardings(); + + } else { + $scope.creationBox = false; + $scope.emailDetails = false; + $scope.forwardLoading = true; + $scope.forwardError = false; + $scope.forwardSuccess = true; + $scope.couldNotConnect = true; + $scope.notifyBox = false; + + $scope.errorMessage = response.data.error_message; + + } + + + } + + function cantLoadInitialDatas(response) { + + $scope.creationBox = true; + $scope.emailDetails = true; + $scope.forwardLoading = true; + $scope.forwardError = true; + $scope.forwardSuccess = true; + $scope.couldNotConnect = false; + $scope.notifyBox = false; + + + } + + + }; + + }); \ No newline at end of file diff --git a/mailServer/templates/mailServer/changeEmailPasswordV2.html b/mailServer/templates/mailServer/changeEmailPasswordV2.html new file mode 100644 index 000000000..9120dca6e --- /dev/null +++ b/mailServer/templates/mailServer/changeEmailPasswordV2.html @@ -0,0 +1,118 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
    +
    +

    Change Email Password

    +

    Select a website from the list, to change its + password.

    +
    +
    +
    +

    Change Email Password

    + +
    +
    + {% if not status %} +
    +

    {% trans "Postfix is disabled." %} + + +

    +
    + {% else %} +
    +
    +
    +

    Select Website

    +
    +
    + +
    +
    +
    +
    +

    Select Email

    +
    +
    + +
    +
    +
    +
    +

    Password

    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +

    Generated Password

    +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    +
    +
    +
    +
    +

    {% trans "Cannot delete email account. Error message:" %} {$ errorMessage + $}

    +
    +
    +

    {% trans "Password successfully changed for :" %} {$ passEmail $}.

    +
    +
    +

    {% trans "Could not connect to server. Please refresh this page." %}

    +
    +
    +

    {% trans "Currently no email accounts exist for this domain." %}

    +
    +
    + {% endif %} +
    +{% endblock %} diff --git a/mailServer/templates/mailServer/deleteEmailAccountV2.html b/mailServer/templates/mailServer/deleteEmailAccountV2.html new file mode 100644 index 000000000..01dcc7ac9 --- /dev/null +++ b/mailServer/templates/mailServer/deleteEmailAccountV2.html @@ -0,0 +1,94 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
    +
    +

    Delete Email Account

    +

    Select a website from the list, to delete an email + account.

    +
    +
    +
    +

    Delete Email Account

    + +
    +
    + {% if not status %} + +
    +

    {% trans "Postfix is disabled." %} + + +

    +
    + {% else %} +
    +
    +
    +

    Select Website

    +
    +
    + +
    +
    +
    +
    +

    Select Email

    +
    +
    + +
    +
    +
    + +
    +
    + +
    + +
    + +
    +
    +

    {% trans "Cannot delete email account. Error message:" %} {$ errorMessage + $}

    +
    +
    +

    {% trans "Mailbox with username: {$ deletedID $} has been successfully deleted." %}

    +
    +
    +

    {% trans "Could not connect to server. Please refresh this page." %}

    +
    +
    +

    {% trans "Currently no email accounts exist for this domain." %}

    +
    +
    +
    +
    + {% endif %} +
    +
    +{% endblock %} diff --git a/mailServer/templates/mailServer/dkimManagerV2.html b/mailServer/templates/mailServer/dkimManagerV2.html new file mode 100644 index 000000000..85fca5d47 --- /dev/null +++ b/mailServer/templates/mailServer/dkimManagerV2.html @@ -0,0 +1,152 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
    +
    +
    +

    DKIM Manager -

    + {% trans "DKIM Docs" %} +
    +
    + {% if openDKIMInstalled == 0 %} +
    +
    +

    DKIM Manager

    + +
    +
    +
    +

    {% trans "OpenDKIM is not installed. " %} + {% trans "Install Now" %} +

    +
    +
    +
    +
    +
    +

    {% trans "Error message: " %} {$ errorMessage $}

    +
    + +
    +

    {% trans "Could not connect. Please refresh this page." %}

    +
    + +
    +

    {% trans "OpenDKIM successfully installed, refreshing page in 3 seconds.." %}

    +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    + + + + {% else %} +
    +

    + {% trans "DKIM Manager" %} +

    +
    + +
    + +
    +
    +

    Select Website

    +
    +
    + +
    +
    +
    +
    +
    + +
    +

    {% trans "Keys not available for this domain." %} + {% trans "Generate Now" %} +

    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + +
    + Domain + + Private Key + + Public Key +
    + + + + +
    +
    + + +
    +
    +

    {$ dkimSuccessMessage $}

    +
    +
    +

    {$ errorMessage $}

    +
    +
    +

    {% trans "Could not connect to server. Please refresh this page." %}

    +
    +
    +
    +
    +
    + {% endif %} +
    +
    +{% endblock %} diff --git a/mailServer/templates/mailServer/emailForwardingV2.html b/mailServer/templates/mailServer/emailForwardingV2.html new file mode 100644 index 000000000..5c7534ee3 --- /dev/null +++ b/mailServer/templates/mailServer/emailForwardingV2.html @@ -0,0 +1,141 @@ +{% extends "baseTemplate/newBase.html" %} +{% load i18n %} +{% block titleNew %}{% trans "Home - CyberPanel" %}{% endblock %} +{% block newContent %} + + {% load static %} + +
    +
    +

    Setup Email Forwarding -

    + {% trans "Forwarding Docs" %} +
    +
    +
    +

    Setup Email Forwarding

    + +
    +
    + {% if not status %} + +
    +

    {% trans "Postfix is disabled." %} + + +

    +
    + {% else %} +
    +
    +
    +

    Select Website

    +
    +
    + +
    +
    +
    +
    +

    Select Email

    +
    +
    + +
    +
    +
    +
    +

    Forwarding Options

    +
    +
    + +
    +
    +
    +
    +
    +
    +

    {$ errorMessage $}

    +
    + +
    +

    {$ successMessage $}

    +
    +
    +

    {% trans "Could not connect to server. Please refresh this page." %}

    +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + +
    + ID + + Source + + Destination + + Actions +
    + + + + +
    +
    + {% endif %} +
    +{% endblock %} diff --git a/mailServer/templates/mailServer/listEmailsV2.html b/mailServer/templates/mailServer/listEmailsV2.html index 59d488000..f606ca4bb 100644 --- a/mailServer/templates/mailServer/listEmailsV2.html +++ b/mailServer/templates/mailServer/listEmailsV2.html @@ -9,17 +9,16 @@
    -

    List Email Accounts - -

    -
    -
    - {% trans "Debug Email Issues" %} +
    +

    List Email Accounts -

    + {% trans "Debug Email Issues" %} +
    {% trans "Create Email" %} + href="{% url "createEmailAccountV2" %}">{% trans "Create Email" %}

    List Emails Accounts. Change their passwords or delete @@ -60,196 +59,205 @@

    -
    -
    +
    +

    {% 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.

    - - + +
    -
    - -

    {% trans "Details To Configure Mail Clients" %}

    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    {% trans "POP3" %}{% trans "Details" %}
    {% trans "Server Hostname" %}{$ serverHostname $}
    {% trans "Port" %}110
    {% trans "Port" %}995 (SSL)
    {% trans "SSL" %}STARTTLS
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    {% trans "IMAP" %}{% trans "Details" %}
    {% trans "Server Hostname" %}{$ serverHostname $}
    {% trans "Port" %}143
    {% trans "Port" %}993 (SSL)
    {% trans "SSL" %}STARTTLS
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    {% trans "SMTP" %}{% trans "Details" %}
    {% trans "Server Hostname" %}{$ serverHostname $}
    {% trans "Port" %}25
    {% trans "Port" %}587 (SSL)
    {% trans "Port" %}465 (SSL)
    {% trans "SSL" %}STARTTLS
    +
    +

    Details To Configure Mail Clients

    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    + POP3 + + Details +
    + Server Hostname + + {$ serverHostname $} +
    + Port + + 110 +
    + Port + + 995 (SSL) +
    + SSL + + STARTTLS +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    + IMAP + + Details +
    + Server Hostname + + {$ serverHostname $} +
    + Port + + 143 +
    + Port + + 993 (SSL) +
    + SSL + + STARTTLS +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    + SMTP + + Details +
    + Server Hostname + + {$ serverHostname $} +
    + Port + + 25 +
    + Port + + 587 (SSL) +
    + 465 (SSL) + + STARTTLS +
    +
    -
    - - - - - - - - - - - - - - - - -
    {% trans "Emails" %}{% trans "Disk Usage" %}{% trans "Actions" %}
    - {% trans 'Change Password' %} - {% trans 'Delete' %} - - - - -
    +
    +
    +
    + + + + + + + + + + + + + + + +
    + Emails + + Disk Usage + + Actions +
    + + + + +
    +
    +
    {% endif %}
    diff --git a/mailServer/urls.py b/mailServer/urls.py index 0f10fb752..7eff79e1f 100755 --- a/mailServer/urls.py +++ b/mailServer/urls.py @@ -10,33 +10,33 @@ urlpatterns = [ url(r'^submitEmailCreation', views.submitEmailCreation, name='submitEmailCreation'), url(r'^fetchEmails$', views.fetchEmails, name='fetchEmails'), - ## Mail Forwardings url(r'^emailForwarding$', views.emailForwarding, name='emailForwarding'), + url(r'^V2/emailForwardingV2$', views.emailForwardingV2, name='emailForwardingV2'), url(r'^submitEmailForwardingCreation$', views.submitEmailForwardingCreation, name='submitEmailForwardingCreation'), url(r'^fetchCurrentForwardings$', views.fetchCurrentForwardings, name='fetchCurrentForwardings'), url(r'^submitForwardDeletion$', views.submitForwardDeletion, name='submitForwardDeletion'), - ## Delete email url(r'^deleteEmailAccount', views.deleteEmailAccount, name='deleteEmailAccount'), + url(r'^V2/deleteEmailAccountV2', views.deleteEmailAccountV2, name='deleteEmailAccountV2'), url(r'^getEmailsForDomain$', views.getEmailsForDomain, name='getEmailsForDomain'), url(r'^submitEmailDeletion', views.submitEmailDeletion, name='submitEmailDeletion'), url(r'^fixMailSSL', views.fixMailSSL, name='fixMailSSL'), - ## Change email password url(r'^changeEmailAccountPassword', views.changeEmailAccountPassword, name='changeEmailAccountPassword'), + url(r'^V2/changeEmailAccountPasswordV2', views.changeEmailAccountPasswordV2, name='changeEmailAccountPasswordV2'), url(r'^submitPasswordChange', views.submitPasswordChange, name='submitPasswordChange'), ## DKIM Manager url(r'^dkimManager', views.dkimManager, name='dkimManager'), + url(r'^V2/dkimManagerV2', views.dkimManagerV2, name='dkimManagerV2'), url(r'^fetchDKIMKeys', views.fetchDKIMKeys, name='fetchDKIMKeys'), url(r'^generateDKIMKeys$', views.generateDKIMKeys, name='generateDKIMKeys'), url(r'^installOpenDKIM', views.installOpenDKIM, name='installOpenDKIM'), url(r'^installStatusOpenDKIM', views.installStatusOpenDKIM, name='installStatusOpenDKIM'), - -] \ No newline at end of file +] diff --git a/mailServer/views.py b/mailServer/views.py index 31fe7670e..99f7bdbd4 100755 --- a/mailServer/views.py +++ b/mailServer/views.py @@ -84,6 +84,14 @@ def deleteEmailAccount(request): return redirect(loadLoginPage) +def deleteEmailAccountV2(request): + try: + msM = MailServerManager(request) + return msM.deleteEmailAccountV2() + except KeyError: + return redirect(loadLoginPage) + + def getEmailsForDomain(request): try: msM = MailServerManager(request) @@ -136,6 +144,14 @@ def emailForwarding(request): return redirect(loadLoginPage) +def emailForwardingV2(request): + try: + msM = MailServerManager(request) + return msM.emailForwardingV2() + except KeyError: + return redirect(loadLoginPage) + + def fetchCurrentForwardings(request): try: msM = MailServerManager(request) @@ -198,6 +214,14 @@ def changeEmailAccountPassword(request): return redirect(loadLoginPage) +def changeEmailAccountPasswordV2(request): + try: + msM = MailServerManager(request) + return msM.changeEmailAccountPasswordV2() + except KeyError: + return redirect(loadLoginPage) + + def submitPasswordChange(request): try: @@ -229,6 +253,14 @@ def dkimManager(request): return redirect(loadLoginPage) +def dkimManagerV2(request): + try: + msM = MailServerManager(request) + return msM.dkimManagerV2() + except KeyError: + return redirect(loadLoginPage) + + def fetchDKIMKeys(request): try: msM = MailServerManager(request) diff --git a/upgrade.sh b/upgrade.sh index 2424f55b8..b387b67c7 100755 --- a/upgrade.sh +++ b/upgrade.sh @@ -15,4 +15,4 @@ find /usr/local/CyberCP -type f -exec chmod 0644 {} \; chmod -R 755 /usr/local/CyberCP/bin chown -R root:root /usr/local/CyberCP chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin/tmp -systemctl restart lscpd +systemctl restart lscpd \ No newline at end of file