diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 90ef6a5ea..b4837b05c 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -740,7 +740,7 @@ module cyberpanel_ols { with open('/etc/cyberpanel/webmail.conf', 'w') as f: json_module.dump(webmail_conf, f) os.chmod('/etc/cyberpanel/webmail.conf', 0o600) - subprocess.call(['chown', 'nobody:nobody', '/etc/cyberpanel/webmail.conf']) + subprocess.call(['chown', 'cyberpanel:cyberpanel', '/etc/cyberpanel/webmail.conf']) InstallCyberPanel.stdOut("Webmail master user setup complete!", 1) return 1 diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 64b550628..1fa7e3b2e 100644 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -2846,7 +2846,7 @@ CREATE TABLE `websiteFunctions_backupsv2` (`id` integer AUTO_INCREMENT NOT NULL with open('/etc/cyberpanel/webmail.conf', 'w') as f: json.dump(webmail_conf, f) os.chmod('/etc/cyberpanel/webmail.conf', 0o600) - subprocess.call(['chown', 'nobody:nobody', '/etc/cyberpanel/webmail.conf']) + subprocess.call(['chown', 'cyberpanel:cyberpanel', '/etc/cyberpanel/webmail.conf']) # Patch dovecot.conf if master user config not present dovecot_conf_path = '/etc/dovecot/dovecot.conf' diff --git a/webmail/static/webmail/webmail.js b/webmail/static/webmail/webmail.js index 7a80f0d52..4d46ab32d 100644 --- a/webmail/static/webmail/webmail.js +++ b/webmail/static/webmail/webmail.js @@ -171,6 +171,8 @@ app.controller('webmailCtrl', ['$scope', '$http', '$sce', '$timeout', function($ $scope.switchEmail = data.email; $scope.loadFolders(); $scope.loadSettings(); + } else { + notify(data.error_message || 'No email accounts found. Create an email account first or use the standalone login.', 'error'); } }); }; @@ -199,6 +201,8 @@ app.controller('webmailCtrl', ['$scope', '$http', '$sce', '$timeout', function($ if (data.status === 1) { $scope.folders = data.folders; $scope.loadMessages(); + } else { + notify(data.error_message || 'Failed to load folders.', 'error'); } }); }; diff --git a/webmail/webmailManager.py b/webmail/webmailManager.py index ece2e07ff..61a6cd81d 100644 --- a/webmail/webmailManager.py +++ b/webmail/webmailManager.py @@ -184,9 +184,12 @@ class WebmailManager: accounts = self._get_managed_accounts() if not accounts: return self._error('No email accounts found for your user.') - email = accounts[0] - self.request.session['webmail_email'] = email - return self._success({'email': email, 'accounts': accounts}) + # Preserve previously selected account if still valid + current = self.request.session.get('webmail_email') + if not current or current not in accounts: + current = accounts[0] + self.request.session['webmail_email'] = current + return self._success({'email': current, 'accounts': accounts}) def apiListAccounts(self): accounts = self._get_managed_accounts()