diff --git a/server/plugins-available/mail_plugin.inc.php b/server/plugins-available/mail_plugin.inc.php index ef7f7499ba1fc19b23c1f01c0dec8f9beab1afd8..c4f496b9c91b395451d6f470dd345bd50eea5dd0 100644 --- a/server/plugins-available/mail_plugin.inc.php +++ b/server/plugins-available/mail_plugin.inc.php @@ -480,8 +480,15 @@ class mail_plugin { //* Delete maildomain path $old_maildomain_path = $mail_config['homedir_path'].'/'.$data['old']['domain']; if($old_maildomain_path != $mail_config['homedir_path'] && !stristr($old_maildomain_path, '//') && !stristr($old_maildomain_path, '..') && !stristr($old_maildomain_path, '*') && !stristr($old_maildomain_path, '&') && strlen($old_maildomain_path) >= 10 && !empty($data['old']['domain'])) { - $app->system->exec_safe('rm -rf ?', $old_maildomain_path); - $app->log('Deleted the mail domain directory: '.$old_maildomain_path, LOGLEVEL_DEBUG); + if ($mail_config['mailbox_safe_delete'] == 'n') { + $app->system->exec_safe('rm -rf ?', $old_maildomain_path); + $app->log('Deleted the mail domain directory: '.$old_maildomain_path, LOGLEVEL_DEBUG); + } else { + // Move it, adding a date based suffix. A cronjob should purge or archive. + $thrash_maildomain_path = $old_maildomain_path . '-' . date("YmdHis"); + $app->system->exec_safe('mv ? ?', $old_maildomain_path, $thrash_maildomain_path); + $app->log('Renamed the mail domain directory: ' . $old_maildomain_path . ' to ' . $thrash_maildomain_path, LOGLEVEL_DEBUG); + } $maildomain_path_deleted = true; } else { $app->log('Possible security violation when deleting the mail domain directory: '.$old_maildomain_path, LOGLEVEL_ERROR);