diff --git a/CHANGELOG b/CHANGELOG
index c0895fcbe5..eaeebb9a6d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,6 +12,9 @@ BACKEND
DISTRIBUTION
Fixed: Make sure that sendmail* packages are pre-uninstalled
+FRONTEND
+ Readded: Mailboxes quota information (info are retrieved by parsing maildirsize file)
+
LISTENERS
Updated: Add Referrer-Policy header to 40_apache2_security_headers.pl listener file
diff --git a/configs/debian/frontend/php-fpm.conf b/configs/debian/frontend/php-fpm.conf
index 588e95a285..352a60ece6 100644
--- a/configs/debian/frontend/php-fpm.conf
+++ b/configs/debian/frontend/php-fpm.conf
@@ -23,7 +23,7 @@ pm.max_requests = {FRONTEND_FCGI_MAX_REQUEST}
chdir = /
security.limit_extensions = .php .php3 .php4 .php5 .php7 .pht .phtml
env[TMPDIR] = {WEB_DIR}/data/tmp
-php_admin_value[open_basedir] = {HOME_DIR}/:{CONF_DIR}/:{PEAR_DIR}/:{DISTRO_OPENSSL_CNF}:{DISTRO_CA_BUNDLE}:{RKHUNTER_LOG}:{CHKROOTKIT_LOG}{OTHER_ROOTKIT_LOG}:/proc/:/bin/df:/bin/mount:/dev/random:/dev/urandom
+php_admin_value[open_basedir] = {HOME_DIR}/:{CONF_DIR}/:{PEAR_DIR}/:{MTA_VIRTUAL_MAIL_DIR}/:{DISTRO_OPENSSL_CNF}:{DISTRO_CA_BUNDLE}:{RKHUNTER_LOG}:{CHKROOTKIT_LOG}{OTHER_ROOTKIT_LOG}:/proc/:/bin/df:/bin/mount:/dev/random:/dev/urandom
php_value[max_execution_time] = 120
php_value[max_input_time] = 600
php_value[memory_limit] = 256M
diff --git a/engine/PerlLib/Package/FrontEnd/Installer.pm b/engine/PerlLib/Package/FrontEnd/Installer.pm
index 1ce857ed6a..c419da4300 100644
--- a/engine/PerlLib/Package/FrontEnd/Installer.pm
+++ b/engine/PerlLib/Package/FrontEnd/Installer.pm
@@ -45,6 +45,7 @@ use Net::LibIDN qw/ idn_to_ascii idn_to_unicode /;
use Package::FrontEnd;
use Servers::httpd;
use Servers::named;
+use Servers::mta;
use version;
use parent 'Common::SingletonClass';
@@ -809,6 +810,9 @@ sub _addMasterWebUser
}
$rs = iMSCP::SystemUser->new( username => $userName )->addToGroup( $main::imscpConfig{'IMSCP_GROUP'} );
+ $rs = iMSCP::SystemUser->new( username => $userName )->addToGroup(
+ Servers::mta->factory()->{'config'}->{'MTA_MAILBOX_GID_NAME'}
+ );
$rs ||= iMSCP::SystemUser->new( username => $self->{'config'}->{'HTTPD_USER'} )->addToGroup( $groupName );
$rs ||= $self->{'eventManager'}->trigger( 'afterHttpdAddUser' );
}
@@ -932,12 +936,13 @@ sub _buildPhpConfig
FRONTEND_GROUP => $group,
FRONTEND_USER => $user,
HOME_DIR => $main::imscpConfig{'GUI_ROOT_DIR'},
+ MTA_VIRTUAL_MAIL_DIR => Servers::mta->factory()->{'config'}->{'MTA_VIRTUAL_MAIL_DIR'},
PEAR_DIR => $self->{'phpConfig'}->{'PHP_PEAR_DIR'},
OTHER_ROOTKIT_LOG => $main::imscpConfig{'OTHER_ROOTKIT_LOG'} ne ''
? ":$main::imscpConfig{'OTHER_ROOTKIT_LOG'}" : '',
RKHUNTER_LOG => $main::imscpConfig{'RKHUNTER_LOG'},
TIMEZONE => main::setupGetQuestion( 'TIMEZONE' ),
- WEB_DIR => $main::imscpConfig{'GUI_ROOT_DIR'},
+ WEB_DIR => $main::imscpConfig{'GUI_ROOT_DIR'}
},
{
destination => "/usr/local/etc/imscp_panel/php-fpm.conf",
diff --git a/gui/library/Functions/Client.php b/gui/library/Functions/Client.php
index 014a406e8f..5dcd015fde 100644
--- a/gui/library/Functions/Client.php
+++ b/gui/library/Functions/Client.php
@@ -520,3 +520,36 @@ function send_alias_order_email($aliasName)
return true;
}
+
+/**
+ * Get mailbox quota info from the given maildirsize file
+ *
+ * @param string $maildirsizeFilePath
+ * @return array|bool Array containing IMAP quota info on success, FALSE on failure
+ */
+function getMailboxQuotaInfo($maildirsizeFilePath)
+{
+ if (!@is_readable($maildirsizeFilePath)) {
+ return false;
+ }
+
+ $fh = @fopen($maildirsizeFilePath, 'r');
+ if (!$fh) {
+ return false;
+ }
+
+ $info = array(
+ 'MAILBOX_QUOTA' => $quota = substr(rtrim(fgets($fh)), 0, -1),
+ 'MAILBOX_SIZE' => 0,
+ 'MAILBOX_MSGS' => 0
+ );
+
+ while (($line = fgets($fh)) !== false) {
+ list($msgsize, $msgcount) = preg_split('/\s+/', $line);
+ $info['MAILBOX_SIZE'] += $msgsize;
+ $info['MAILBOX_MSGS'] += $msgcount;
+ }
+
+ fclose($fh);
+ return $info;
+}
diff --git a/gui/public/client/mail_accounts.php b/gui/public/client/mail_accounts.php
index 6b8d6ace60..00c777ceba 100644
--- a/gui/public/client/mail_accounts.php
+++ b/gui/public/client/mail_accounts.php
@@ -135,6 +135,10 @@ function _client_generateMailAccountsList($tpl, $mainDmnId)
$dmnProps = get_domain_default_props($_SESSION['user_id']);
+
+ $postfixConfig = new iMSCP_Config_Handler_File(
+ utils_normalizePath(iMSCP_Registry::get('config')->CONF_DIR . '/postfix/postfix.data')
+ );
while ($row = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
list($mailDelete, $mailDeleteScript, $mailEdit, $mailEditScript) = _client_generateUserMailAction(
@@ -155,23 +159,37 @@ function _client_generateMailAccountsList($tpl, $mainDmnId)
$mailType .= '
';
}
+ if((strpos($row['mail_type'], '_mail') !== false)) {
+ list($user, $domain) = explode('@', $row['mail_addr']);
+ $info = getMailboxQuotaInfo(utils_normalizePath(
+ $postfixConfig['MTA_VIRTUAL_MAIL_DIR'] . "/$domain/$user/maildirsize"
+ ));
+
+ if($info !== FALSE) {
+ $mailQuotaInfo = tr(
+ '%s / %s of %s total available',
+ bytesHuman($info['MAILBOX_SIZE'], NULL, 0),
+ bytesHuman($info['MAILBOX_QUOTA'], NULL, 0),
+ ($dmnProps['mail_quota'] > 0) ? bytesHuman($dmnProps['mail_quota'], NULL, 0) : tr('Unlimited')
+ );
+ } else {
+ $mailQuotaInfo = tr('Unknown');
+ }
+ } else {
+ $mailQuotaInfo = tr('N/A');
+ }
+
$tpl->assign(array(
- 'MAIL_ADDR' => tohtml(decode_idna($mailAddr)),
- 'MAIL_TYPE' => $mailType,
- 'MAIL_QUOTA_ASSIGMENT' => (is_null($row['quota']))
- ? tr('N/A')
- : tohtml(tr('%s of %s',
- bytesHuman($row['quota'], NULL, 0),
- ($dmnProps['mail_quota'] == 0)
- ? tr('Unlimited') : tr('%s total available', bytesHuman($dmnProps['mail_quota'], NULL, 0))
- )),
- 'MAIL_STATUS' => translate_dmn_status($row['status']),
- 'MAIL_DELETE' => $mailDelete,
- 'MAIL_DELETE_SCRIPT' => $mailDeleteScript,
- 'MAIL_EDIT' => $mailEdit,
- 'MAIL_EDIT_SCRIPT' => $mailEditScript,
- 'DEL_ITEM' => $row['mail_id'],
- 'DISABLED_DEL_ITEM' => ($row['status'] != 'ok') ? ' disabled' : ''
+ 'MAIL_ADDR' => tohtml(decode_idna($mailAddr)),
+ 'MAIL_TYPE' => $mailType,
+ 'MAIL_QUOTA_INFO' => tohtml($mailQuotaInfo),
+ 'MAIL_STATUS' => translate_dmn_status($row['status']),
+ 'MAIL_DELETE' => $mailDelete,
+ 'MAIL_DELETE_SCRIPT' => $mailDeleteScript,
+ 'MAIL_EDIT' => $mailEdit,
+ 'MAIL_EDIT_SCRIPT' => $mailEditScript,
+ 'DEL_ITEM' => $row['mail_id'],
+ 'DISABLED_DEL_ITEM' => ($row['status'] != 'ok') ? ' disabled' : ''
));
_client_generateUserMailAutoRespond($tpl, $row['mail_id'], $row['status'], $row['mail_auto_respond']);
@@ -251,7 +269,7 @@ function client_generatePage($tpl)
'TR_PAGE_TITLE' => tr('Client / Email / Overview'),
'TR_MAIL' => tr('Mail'),
'TR_TYPE' => tr('Type'),
- 'TR_QUOTA_ASSIGNMENT' => tr('Quota assignment'),
+ 'TR_QUOTA_INFO' => tr('Quota info'),
'TR_STATUS' => tr('Status'),
'TR_ACTIONS' => tr('Actions'),
'TR_AUTORESPOND' => tr('Auto responder'),
diff --git a/gui/themes/default/client/mail_accounts.tpl b/gui/themes/default/client/mail_accounts.tpl
index c3d570e98d..04b70dd7ca 100644
--- a/gui/themes/default/client/mail_accounts.tpl
+++ b/gui/themes/default/client/mail_accounts.tpl
@@ -64,7 +64,7 @@