Skip to content

Commit 58023ff

Browse files
author
Florian Schaal
committed
use doveadm instead of 'du -s' for email-quota
1 parent 4ad9487 commit 58023ff

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

server/lib/classes/cron.d/100-monitor_email_quota.inc.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,20 @@ public function onRunJob() {
7777

7878
$mailboxes = $app->db->queryAllRecords("SELECT email,maildir FROM mail_user WHERE server_id = $server_id");
7979
if(is_array($mailboxes)) {
80+
81+
//* with dovecot we can use doveadm instead of 'du -s'
82+
$dovecot = false;
83+
if (isset($mail_config['pop3_imap_daemon']) && $mail_config ['pop3_imap_daemon'] = 'dovecot' && is_executable('doveadm')) {
84+
$dovecot = true;
85+
}
86+
8087
foreach($mailboxes as $mb) {
8188
$email = $mb['email'];
8289
$email_parts = explode('@', $mb['email']);
8390
$filename = $mb['maildir'].'/.quotausage';
91+
if(!file_exists($filename) && $dovecot) {
92+
exec('doveadm quota recalc -u '.$email);
93+
}
8494
if(file_exists($filename) && !is_link($filename)) {
8595
$quotafile = file($filename);
8696
preg_match('/storage.*?([0-9]+)/s', implode('',$quotafile), $storage_value);

0 commit comments

Comments
 (0)