diff --git a/actions/admin/settings/150.mail.php b/actions/admin/settings/150.mail.php index db4d58bf..fc514f37 100644 --- a/actions/admin/settings/150.mail.php +++ b/actions/admin/settings/150.mail.php @@ -51,6 +51,15 @@ return array( 'default' => '/var/customers/mail/', 'save_method' => 'storeSettingField', ), + 'system_vmail_maildirname' => array( + 'label' => $lng['serversettings']['vmail_maildirname'], + 'settinggroup' => 'system', + 'varname' => 'vmail_maildirname', + 'type' => 'string', + 'string_type' => 'dir', + 'default' => 'Maildir', + 'save_method' => 'storeSettingField', + ), 'panel_sendalternativemail' => array( 'label' => $lng['serversettings']['sendalternativemail'], 'settinggroup' => 'panel', @@ -95,4 +104,4 @@ return array( ), ); -?> \ No newline at end of file +?> diff --git a/customer_email.php b/customer_email.php index 86356910..acc6b9de 100644 --- a/customer_email.php +++ b/customer_email.php @@ -440,12 +440,37 @@ elseif($page == 'accounts') } $email_user=substr($email_full,0,strrpos($email_full,"@")); $email_domain=substr($email_full,strrpos($email_full,"@")+1); + $maildirname=trim($settings['system']['vmail_maildirname']); + // Add trailing slash to Maildir if needed + $maildirpath=$maildirname; + if (!empty($maildirname) and substr($maildirname,-1) != "/") $maildirpath.="/"; - $db->query("INSERT INTO `" . TABLE_MAIL_USERS . "` (`customerid`, `email`, `username`, " . ($settings['system']['mailpwcleartext'] == '1' ? '`password`, ' : '') . " `password_enc`, `homedir`, `maildir`, `uid`, `gid`, `domainid`, `postfix`, `quota`, `imap`, `pop3`) VALUES ('" . (int)$userinfo['customerid'] . "', '" . $db->escape($email_full) . "', '" . $db->escape($username) . "', " . ($settings['system']['mailpwcleartext'] == '1' ? "'" . $db->escape($password) . "'," : '') . " ENCRYPT('" . $db->escape($password) . "'), '" . $db->escape($settings['system']['vmail_homedir']) . "', '" . $db->escape($userinfo['loginname'] . '/' . $email_domain . "/" . $email_user . '/Maildir/') . "', '" . (int)$settings['system']['vmail_uid'] . "', '" . (int)$settings['system']['vmail_gid'] . "', '" . (int)$result['domainid'] . "', 'y', '" . (int)$quota . "', '" . (int)$userinfo['imap'] . "', '" . (int)$userinfo['pop3'] . "')"); + $db->query("INSERT INTO `" . TABLE_MAIL_USERS . + "` (`customerid`, `email`, `username`, " . ($settings['system']['mailpwcleartext'] == '1' ? '`password`, ' : '') . " `password_enc`, `homedir`, `maildir`, `uid`, `gid`, `domainid`, `postfix`, `quota`, `imap`, `pop3`) ". + "VALUES (". + "'" . (int)$userinfo['customerid'] . "', ". + "'" . $db->escape($email_full) . "', ". + "'" . $db->escape($username) . "', " . + ($settings['system']['mailpwcleartext'] == '1' ? "'" . $db->escape($password) . "', " : '') . + "ENCRYPT('" . $db->escape($password) . "'), ". + "'" . $db->escape($settings['system']['vmail_homedir']) . "', '" . $db->escape($userinfo['loginname'] . '/' . $email_domain . "/" . $email_user . "/" . $maildirpath) . "', ". + "'" . (int)$settings['system']['vmail_uid'] . "', ". + "'" . (int)$settings['system']['vmail_gid'] . "', ". + "'" . (int)$result['domainid'] . "', ". + "'y', ". + "'" . (int)$quota . "', ". + "'" . (int)$userinfo['imap'] . "', ". + "'" . (int)$userinfo['pop3'] . "')"); $popaccountid = $db->insert_id(); $result['destination'].= ' ' . $email_full; - $db->query("UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `destination` = '" . $db->escape(makeCorrectDestination($result['destination'])) . "', `popaccountid` = '" . (int)$popaccountid . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'"); - $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `email_accounts_used`=`email_accounts_used`+1, `email_quota_used`=`email_quota_used`+" . (int)$quota . " WHERE `customerid`='" . (int)$userinfo['customerid'] . "'"); + $db->query("UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET ". + "`destination` = '" . $db->escape(makeCorrectDestination($result['destination'])) . "', ". + "`popaccountid` = '" . (int)$popaccountid . "' ". + "WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'"); + $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET ". + "`email_accounts_used`=`email_accounts_used`+1, ". + "`email_quota_used`=`email_quota_used`+" . (int)$quota . " ". + "WHERE `customerid`='" . (int)$userinfo['customerid'] . "'"); $log->logAction(USR_ACTION, LOG_INFO, "added email account for '" . $email_full . "'"); $replace_arr = array( 'EMAIL' => $email_full, diff --git a/lib/functions/filedir/function.maildirExists.php b/lib/functions/filedir/function.maildirExists.php index 5d61cc34..516a940f 100644 --- a/lib/functions/filedir/function.maildirExists.php +++ b/lib/functions/filedir/function.maildirExists.php @@ -30,7 +30,10 @@ function maildirExists($result = null) { $loginname = getCustomerDetail($result['customerid'], 'loginname'); if($loginname !== false) { - $maildir = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $loginname .'/'. $result['email_full']); + $email_user=substr($result['email_full'],0,strrpos($result['email_full'],"@")); + $email_domain=substr($result['email_full'],strrpos($result['email_full'],"@")+1); + $maildirname=trim($settings['system']['vmail_maildirname']); + $maildir = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $loginname .'/'. $email_domain .'/'. $email_user . (!empty($maildirname)?'/'.$maildirname:'')); if(@file_exists($maildir)) { return true; } diff --git a/lib/functions/froxlor/function.CronjobFunctions.php b/lib/functions/froxlor/function.CronjobFunctions.php index 2ef4063e..ad1c208d 100644 --- a/lib/functions/froxlor/function.CronjobFunctions.php +++ b/lib/functions/froxlor/function.CronjobFunctions.php @@ -209,6 +209,10 @@ function getOutstandingTasks() $task_desc = $lng['tasks']['deleting_customerfiles']; $task_desc = str_replace('%loginname%', $loginname, $task_desc); } + elseif($row['type'] == '7') + { + $task_desc = $lng['tasks']['remove_emailacc_files']; + } /* * Set FS - quota */ diff --git a/lng/english.lng.php b/lng/english.lng.php index 5e1ad674..0fb773da 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -1917,3 +1917,7 @@ $lng['panel']['cancel'] = 'Cancel'; $lng['admin']['delete_statistics'] = 'Delete Statistics'; $lng['admin']['speciallogwarning'] = 'WARNING: By changing this setting you will lose all your old statistics for this domain. If you are 100% sure you wish to change this type "'.$lng['admin']['delete_statistics'].'" in the field below and click the "'.$lng['panel']['delete'].'" button.

'; +// ADDED IN 0.9.28-svn2 +$lng['serversettings']['vmail_maildirname']['title'] = 'Maildir name'; +$lng['serversettings']['vmail_maildirname']['description'] = 'Maildir directory into user\'s account. Normally \'Maildir\', in some implementations \'.maildir\', and directly into user\'s directory if left blank.'; +$lng['tasks']['remove_emailacc_files'] = 'Delete customer e-mail data.'; diff --git a/scripts/jobs/cron_tasks.php b/scripts/jobs/cron_tasks.php index 874fa213..94216b04 100644 --- a/scripts/jobs/cron_tasks.php +++ b/scripts/jobs/cron_tasks.php @@ -310,7 +310,6 @@ while($row = $db->fetch_array($result_tasks)) safe_exec('rm -rf '.escapeshellarg($backupdir)); } - /* * remove maildir */ @@ -318,7 +317,10 @@ while($row = $db->fetch_array($result_tasks)) if($maildir != '/' && $maildir != $settings['system']['vmail_homedir'] - && substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir']) + && substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir'] + && is_dir($maildir) + && fileowner($maildir) == $settings['system']['vmail_uid'] + && filegroup($maildir) == $settings['system']['vmail_gid']) { $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($maildir)); safe_exec('rm -rf '.escapeshellarg($maildir)); @@ -388,11 +390,24 @@ while($row = $db->fetch_array($result_tasks)) /* * remove specific maildir */ - $maildir = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $row['data']['loginname'] .'/'. $row['data']['email']); + $email_full = $row['data']['email']; + if (empty($email_full)) { + $cronlog->logAction(CRON_ACTION, LOG_ERROR, 'FATAL: Task7 asks to delete a email account but email field is empty!'); + } + $email_user=substr($email_full,0,strrpos($email_full,"@")); + $email_domain=substr($email_full,strrpos($email_full,"@")+1); + $maildirname=trim($settings['system']['vmail_maildirname']); + // Add trailing slash to Maildir if needed + $maildirpath=$maildirname; + if (!empty($maildirname) and substr($maildirname,-1) != "/") $maildirpath.="/"; + $maildir = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $row['data']['loginname'] .'/'. $email_domain .'/'. $email_user .'/'. $maildirpath); - if($maildir != '/' + if($maildir != '/' && !empty($maildir) && !empty($email_full) && $maildir != $settings['system']['vmail_homedir'] - && substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir']) + && substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir'] + && is_dir($maildir) + && fileowner($maildir) == $settings['system']['vmail_uid'] + && filegroup($maildir) == $settings['system']['vmail_gid']) { $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($maildir)); safe_exec('rm -rf '.escapeshellarg($maildir));