Dominik
2015-04-25 f339ebf3a37fc23aac843ce1c7008d4a77d87fa8
mdbox format as alternative for Maildir
35 files modified
499 ■■■■■ changed files
install/sql/incremental/upd_dev_collection.sql 1 ●●●● patch | view | raw | blame | history
install/sql/ispconfig3.sql 1 ●●●● patch | view | raw | blame | history
install/tpl/debian6_dovecot-sql.conf.master 4 ●●●● patch | view | raw | blame | history
install/tpl/debian_dovecot-sql.conf.master 4 ●●●● patch | view | raw | blame | history
install/tpl/fedora_dovecot-sql.conf.master 4 ●●●● patch | view | raw | blame | history
install/tpl/opensuse_dovecot-sql.conf.master 4 ●●●● patch | view | raw | blame | history
interface/web/admin/form/server_config.tform.php 6 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/ar_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/bg_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/br_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/cz_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/de_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/el_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/es_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/fi_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/fr_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/hr_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/hu_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/id_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/it_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/ja_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/nl_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/pl_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/pt_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/ro_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/ru_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/se_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/sk_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/tr_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_config_mail_edit.htm 6 ●●●●● patch | view | raw | blame | history
interface/web/mail/mail_user_edit.php 10 ●●●●● patch | view | raw | blame | history
server/lib/classes/cron.d/500-backup_mail.inc.php 60 ●●●● patch | view | raw | blame | history
server/plugins-available/backup_plugin.inc.php 69 ●●●● patch | view | raw | blame | history
server/plugins-available/mail_plugin.inc.php 307 ●●●●● patch | view | raw | blame | history
install/sql/incremental/upd_dev_collection.sql
@@ -37,6 +37,7 @@
ALTER TABLE `sys_datalog` ADD INDEX `dbtable` (`dbtable` (25), `dbidx` (25)), ADD INDEX (`action`);
ALTER TABLE `mail_user` ADD `greylisting` ENUM( 'n', 'y' ) NOT NULL DEFAULT 'n' AFTER `postfix`;
ALTER TABLE `mail_user` ADD `maildir_format` varchar(255) NOT NULL default 'maildir' AFTER `maildir`;
ALTER TABLE `mail_forwarding` ADD `greylisting` ENUM( 'n', 'y' ) NOT NULL DEFAULT 'n' AFTER `active`;
ALTER TABLE `openvz_ip` CHANGE `ip_address` `ip_address` VARCHAR(39) DEFAULT NULL;
install/sql/ispconfig3.sql
@@ -914,6 +914,7 @@
  `uid` int(11) NOT NULL default '5000',
  `gid` int(11) NOT NULL default '5000',
  `maildir` varchar(255) NOT NULL default '',
  `maildir_format` varchar(255) NOT NULL default 'maildir',
  `quota` bigint(20) NOT NULL default '-1',
  `cc` varchar(255) NOT NULL default '',
  `sender_cc` varchar(255) NOT NULL default '',
install/tpl/debian6_dovecot-sql.conf.master
@@ -14,8 +14,8 @@
default_pass_scheme = CRYPT
# password-query with prefetch
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT('maildir:', maildir, '/Maildir') as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
# Do not enable it on Dovecot 1.x servers
install/tpl/debian_dovecot-sql.conf.master
@@ -121,8 +121,8 @@
default_pass_scheme = CRYPT
# password-query with prefetch
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT('maildir:', maildir, '/Maildir') as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
# Do not enable it on Dovecot 1.x servers
install/tpl/fedora_dovecot-sql.conf.master
@@ -134,8 +134,8 @@
default_pass_scheme = CRYPT
# password-query with prefetch
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT('maildir:', maildir, '/Maildir') as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
# Do not enable it on Dovecot 1.x servers
install/tpl/opensuse_dovecot-sql.conf.master
@@ -134,8 +134,8 @@
default_pass_scheme = CRYPT
# password-query with prefetch
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT('maildir:', maildir, '/Maildir') as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}'
# The iterate_query is required for the doveadm command only and works only on dovecot 2 servers.
# Do not enable it on Dovecot 1.x servers
interface/web/admin/form/server_config.tform.php
@@ -295,6 +295,12 @@
            'width' => '40',
            'maxlength' => '255'
        ),
        'maildir_format' => array(
            'datatype' => 'VARCHAR',
            'formtype' => 'SELECT',
            'default' => '20',
            'value' => array('maildir' => 'Maildir', 'mdbox' => 'mdbox')
        ),
        'homedir_path' => array(
            'datatype' => 'VARCHAR',
            'formtype' => 'TEXT',
interface/web/admin/lib/lang/ar_server_config.lng
@@ -19,6 +19,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Module';
$wb['maildir_path_txt'] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Path';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
interface/web/admin/lib/lang/bg_server_config.lng
@@ -17,6 +17,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Модул';
$wb['maildir_path_txt'] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Path';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
interface/web/admin/lib/lang/br_server_config.lng
@@ -18,6 +18,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Módulo';
$wb['maildir_path_txt'] = 'Caminho do diretório Maildir';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Caminho do diretório Home';
$wb['mailuser_uid_txt'] = 'UID usuário de email';
$wb['mailuser_gid_txt'] = 'GID usuário de email';
interface/web/admin/lib/lang/cz_server_config.lng
@@ -19,6 +19,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI cesta k binarnímu balíčku';
$wb['module_txt'] = 'Modul';
$wb['maildir_path_txt'] = 'Cesta k mail adresáři';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Cesta k domácímu adresáři';
$wb['mailuser_uid_txt'] = 'Mail uživatel UID';
$wb['mailuser_gid_txt'] = 'Mail uživatel GID';
interface/web/admin/lib/lang/de_server_config.lng
@@ -18,6 +18,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Modul';
$wb['maildir_path_txt'] = 'Maildir Pfad';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Pfad';
$wb['dkim_path_txt'] = 'DKIM Pfad';
$wb['mailuser_uid_txt'] = 'Mailbenutzer UID';
interface/web/admin/lib/lang/el_server_config.lng
@@ -19,6 +19,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Άρθρωμα';
$wb['maildir_path_txt'] = 'Διαδρομή Maildir';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Διαδρομή Homedir';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
interface/web/admin/lib/lang/en_server_config.lng
@@ -29,6 +29,7 @@
$wb["fastcgi_bin_txt"] = 'FastCGI Bin';
$wb["module_txt"] = 'Module';
$wb["maildir_path_txt"] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb["homedir_path_txt"] = 'Homedir Path';
$wb["dkim_path_txt"] = 'DKIM Path';
$wb["mailuser_uid_txt"] = 'Mailuser UID';
interface/web/admin/lib/lang/es_server_config.lng
@@ -17,6 +17,7 @@
$wb['fastcgi_bin_txt'] = 'Binario de FastCGI';
$wb['module_txt'] = 'Módulo';
$wb['maildir_path_txt'] = 'Ruta de buzones';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Ruta base de correo';
$wb['mailuser_uid_txt'] = 'UID del usuario de correo';
$wb['mailuser_gid_txt'] = 'GID del usuario de correo';
interface/web/admin/lib/lang/fi_server_config.lng
@@ -17,6 +17,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI-binääri';
$wb['module_txt'] = 'Ohjelmaosio';
$wb['maildir_path_txt'] = 'Postilaatikon hakemistopolku';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Kotikansion hakemistopolku';
$wb['mailuser_uid_txt'] = 'Käyttäjätunnus';
$wb['mailuser_gid_txt'] = 'Käyttäjäryhmä';
interface/web/admin/lib/lang/fr_server_config.lng
@@ -17,6 +17,7 @@
$wb['fastcgi_bin_txt'] = 'Exétable FastCGI';
$wb['module_txt'] = 'Module';
$wb['maildir_path_txt'] = 'Chemin Maildir';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Chemin Homedir';
$wb['mailuser_uid_txt'] = 'UID de l\'utilisateur mail';
$wb['mailuser_gid_txt'] = 'GID de l\'utilisateur mail';
interface/web/admin/lib/lang/hr_server_config.lng
@@ -18,6 +18,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Modul';
$wb['maildir_path_txt'] = 'Put do Maildir-a';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Put do početne stranice';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
interface/web/admin/lib/lang/hu_server_config.lng
@@ -17,6 +17,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Modul';
$wb['maildir_path_txt'] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Path';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
interface/web/admin/lib/lang/id_server_config.lng
@@ -19,6 +19,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Modul';
$wb['maildir_path_txt'] = 'Path Direktori Mail';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Path Direktori Home';
$wb['mailuser_uid_txt'] = 'UID Pengguna Mail';
$wb['mailuser_gid_txt'] = 'GID Pengguna Mail';
interface/web/admin/lib/lang/it_server_config.lng
@@ -16,6 +16,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Module';
$wb['maildir_path_txt'] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Path';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
interface/web/admin/lib/lang/ja_server_config.lng
@@ -19,6 +19,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI実行ファイル';
$wb['module_txt'] = 'モジュール';
$wb['maildir_path_txt'] = 'メールディレクトリ';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'ホームディレクトリ';
$wb['mailuser_uid_txt'] = 'メールユーザーのUID';
$wb['mailuser_gid_txt'] = 'メールユーザーのGID';
interface/web/admin/lib/lang/nl_server_config.lng
@@ -19,6 +19,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI bin';
$wb['module_txt'] = 'Module';
$wb['maildir_path_txt'] = 'Maildir pad';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir pad';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
interface/web/admin/lib/lang/pl_server_config.lng
@@ -19,6 +19,7 @@
$wb['fastcgi_bin_txt'] = 'Kosz FastCGI';
$wb['module_txt'] = 'Moduł';
$wb['maildir_path_txt'] = 'Adres poczty e-mail';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Bazowy adres poczty e-mail';
$wb['mailuser_uid_txt'] = 'UID użytkownika e-mail';
$wb['mailuser_gid_txt'] = 'GID użytkownika e-mail';
interface/web/admin/lib/lang/pt_server_config.lng
@@ -18,6 +18,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Módulo';
$wb['maildir_path_txt'] = 'Pasta do Maildir';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Pasta Home';
$wb['mailuser_uid_txt'] = 'UID utilizador de email';
$wb['mailuser_gid_txt'] = 'GID utilizador de email';
interface/web/admin/lib/lang/ro_server_config.lng
@@ -18,6 +18,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Module';
$wb['maildir_path_txt'] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Path';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
interface/web/admin/lib/lang/ru_server_config.lng
@@ -16,6 +16,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Модуль';
$wb['maildir_path_txt'] = 'Путь Maildir';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Путь Homedir';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
interface/web/admin/lib/lang/se_server_config.lng
@@ -17,6 +17,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Module';
$wb['maildir_path_txt'] = 'Maildir Path';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Homedir Path';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
interface/web/admin/lib/lang/sk_server_config.lng
@@ -19,6 +19,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Modul';
$wb['maildir_path_txt'] = 'Maildir Cesta';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Cesta k domovskému adresáru';
$wb['mailuser_uid_txt'] = 'Mailuser UID';
$wb['mailuser_gid_txt'] = 'Mailuser GID';
interface/web/admin/lib/lang/tr_server_config.lng
@@ -19,6 +19,7 @@
$wb['fastcgi_bin_txt'] = 'FastCGI Bin';
$wb['module_txt'] = 'Modül';
$wb['maildir_path_txt'] = 'Mail dizini yolu';
$wb['maildir_format_txt'] = 'Maildir Format';
$wb['homedir_path_txt'] = 'Kullanıcı dizini yolu';
$wb['mailuser_uid_txt'] = 'Mail kullanıcısı UID';
$wb['mailuser_gid_txt'] = 'Mail kullanıcısı GID';
interface/web/admin/templates/server_config_mail_edit.htm
@@ -15,6 +15,12 @@
                <label for="maildir_path" class="col-sm-3 control-label">{tmpl_var name='maildir_path_txt'}</label>
                <div class="col-sm-9"><input type="text" name="maildir_path" id="maildir_path" value="{tmpl_var name='maildir_path'}" class="form-control" /></div></div>
            <div class="form-group">
                <label class="col-sm-3 control-label">{tmpl_var name='maildir_format_txt'}</label>
                <div class="col-sm-9"><select name="maildir_format" id="maildir_format" class="form-control">
                        {tmpl_var name='maildir_format'}
                    </select></div>
            </div>
            <div class="form-group">
                <label for="homedir_path" class="col-sm-3 control-label">{tmpl_var name='homedir_path_txt'}</label>
                <div class="col-sm-9"><input type="text" name="homedir_path" id="homedir_path" value="{tmpl_var name='homedir_path'}" class="form-control" /></div></div>
            <div class="form-group">
interface/web/mail/mail_user_edit.php
@@ -207,6 +207,16 @@
        $app->uses('getconf');
        $mail_config = $app->getconf->get_server_config(!empty($domain["server_id"]) ? $domain["server_id"] : '', 'mail');
        // Set Maildir format
        if ($this->id == 0) {
            $this->dataRecord['maildir_format'] = $sys_config['maildir_format'];
        }
        else {
            // restore Maildir format
            $tmp = $app->db->queryOneRecord("SELECT maildir_format FROM mail_user WHERE mailuser_id = ".$app->functions->intval($this->id));
            $this->dataRecord['maildir_format'] = $tmp['maildir_format'];
        }
        //* compose the email field
        if(isset($_POST["email_local_part"]) && isset($_POST["email_domain"])) {
            $this->dataRecord["email"] = strtolower($_POST["email_local_part"]."@".$app->functions->idn_encode($_POST["email_domain"]));
server/lib/classes/cron.d/500-backup_mail.inc.php
@@ -31,6 +31,7 @@
    // job schedule
    protected $_schedule = '0 0 * * *';
    private $tmp_backup_dir = '';
    /* this function is optional if it contains no custom code */
    public function onPrepare() {
@@ -111,23 +112,46 @@
                        $mail_backup_file = 'mail'.$rec['mailuser_id'].'_'.date('Y-m-d_H-i');
                        $domain_dir=explode('/',$rec['maildir']);
                        $_temp=array_pop($domain_dir);unset($_temp);
                        $domain_dir=implode('/',$domain_dir);
                        $parts=explode('/',$rec['maildir']);
                        $source_dir=array_pop($parts);
                        unset($parts);
                        //* create archives
                        if($backup_mode == 'userzip') {
                            $mail_backup_file.='.zip';
                            exec('cd '.$domain_dir.' && zip '.$mail_backup_dir.'/'.$mail_backup_file.' -b /tmp -r '.$source_dir.' > /dev/null', $tmp_output, $retval);
                        } else {
                            /* Create a tar.gz backup */
                            $mail_backup_file.='.tar.gz';
                            exec(escapeshellcmd('tar pczf '.$mail_backup_dir.'/'.$mail_backup_file.' --directory '.$domain_dir.' '.$source_dir), $tmp_output, $retval);
                        // in case of mdbox -> create backup with doveadm before zipping
                        if ($rec['maildir_format'] == 'mdbox') {
                            if (empty($this->tmp_backup_dir)) $this->tmp_backup_dir = $rec['maildir'];
                            // Create temporary backup-mailbox
                            exec("su -c 'dsync backup -u \"".$rec["email"]."\" mdbox:".$this->tmp_backup_dir."/backup'", $tmp_output, $retval);
                            if($backup_mode == 'userzip') {
                                $mail_backup_file.='.zip';
                                exec('cd '.$this->tmp_backup_dir.' && zip '.$mail_backup_dir.'/'.$mail_backup_file.' -b /tmp -r backup > /dev/null && rm -rf backup', $tmp_output, $retval);
                            }
                            else {
                                $mail_backup_file.='.tar.gz';
                                exec(escapeshellcmd('tar pczf '.$mail_backup_dir.'/'.$mail_backup_file.' --directory '.$this->tmp_backup_dir.' backup && rm -rf '.$this->tmp_backup_dir.'/backup'), $tmp_output, $retval);
                            }
                            if ($retval != 0) {
                                // Cleanup
                                if (file_exists($this->tmp_backup_dir.'/backup')) exec('rm -rf '.$this->tmp_backup_dir.'/backup');
                            }
                        }
                        else {
                            $domain_dir=explode('/',$rec['maildir']);
                            $_temp=array_pop($domain_dir);unset($_temp);
                            $domain_dir=implode('/',$domain_dir);
                            $parts=explode('/',$rec['maildir']);
                            $source_dir=array_pop($parts);
                            unset($parts);
                            //* create archives
                            if($backup_mode == 'userzip') {
                                $mail_backup_file.='.zip';
                                exec('cd '.$domain_dir.' && zip '.$mail_backup_dir.'/'.$mail_backup_file.' -b /tmp -r '.$source_dir.' > /dev/null', $tmp_output, $retval);
                            } else {
                                /* Create a tar.gz backup */
                                $mail_backup_file.='.tar.gz';
                                exec(escapeshellcmd('tar pczf '.$mail_backup_dir.'/'.$mail_backup_file.' --directory '.$domain_dir.' '.$source_dir), $tmp_output, $retval);
                            }
                        }
                        if($retval == 0){
                            chown($mail_backup_dir.'/'.$mail_backup_file, $backupusername);
                            chgrp($mail_backup_dir.'/'.$mail_backup_file, $backupgroup);
@@ -141,6 +165,10 @@
                        } else {
                            /* Backup failed - remove archive */
                            if(is_file($mail_backup_dir.'/'.$mail_backup_file)) unlink($mail_backup_dir.'/'.$mail_backup_file);
                            // And remove backup-mdbox
                            if ($rec['maildir_format'] == 'mdbox') {
                                if(file_exists($rec['maildir'].'/backup'))  exec("su -c 'rm -rf ".$rec['maildir']."/backup'");
                            }
                            $app->log($mail_backup_file.' NOK:'.implode('',$tmp_output), LOGLEVEL_DEBUG);
                        }
                        /* Remove old backups */
server/plugins-available/backup_plugin.inc.php
@@ -204,27 +204,68 @@
                    chown($domain_dir, $mail_config['mailuser_name']);
                    chgrp($domain_dir, $mail_config['mailuser_group']);
                }
                if (!is_dir($record['maildir'])) {
                    mkdir($record['maildir'], 0700); //* never create the full path
                    chown($record['maildir'], $mail_config['mailuser_name']);
                    chgrp($record['maildir'], $mail_config['mailuser_group']);
                }
            
                if(file_exists($mail_backup_file) && $record['homedir'] != '' && $record['homedir'] != '/' && !stristr($mail_backup_file,'..') && !stristr($mail_backup_file,'etc') && $mail_config['homedir_path'] == $record['homedir'] && is_dir($domain_dir)) {
                    if($mail_backup['backup_mode'] == 'userzip') {
                        copy($mail_backup_file, $domain_dir.'/'.$mail_backup['filename']);
                        chgrp($domain_dir.'/'.$mail_backup['filename'], $mail_config['mailuser_group']);
                        $command = 'sudo -u '.$mail_config['mailuser_name'].' unzip -qq -o  '.escapeshellarg($domain_dir.'/'.$mail_backup['filename']).' -d '.escapeshellarg($domain_dir).' 2> /dev/null';
                        exec($command,$tmp_output, $retval);
                        unlink($domain_dir.'/'.$mail_backup['filename']);
                if(file_exists($mail_backup_file) && $record['homedir'] != '' && $record['homedir'] != '/' && !stristr($mail_backup_file,'..') && !stristr($mail_backup_file,'etc') && $mail_config['homedir_path'] == $record['homedir'] && is_dir($domain_dir) && is_dir($record['maildir'])) {
                    if ($record['maildir_format'] == 'mdbox') {
                        $retval = -1;
                        // First unzip backupfile to local backup-folder
                        if($mail_backup['backup_mode'] == 'userzip') {
                            copy($mail_backup_file, $record['maildir'].'/'.$mail_backup['filename']);
                            chgrp($record['maildir'].'/'.$mail_backup['filename'], $mail_config['mailuser_group']);
                            $command = 'sudo -u '.$mail_config['mailuser_name'].' unzip -qq -o  '.escapeshellarg($record['maildir'].'/'.$mail_backup['filename']).' -d '.escapeshellarg($record['maildir']).' 2> /dev/null';
                            exec($command,$tmp_output, $retval);
                            unlink($record['maildir'].'/'.$mail_backup['filename']);
                        }
                        if($mail_backup['backup_mode'] == 'rootgz') {
                            $command='tar xfz '.escapeshellarg($mail_backup_file).' --directory '.escapeshellarg($record['maildir']);
                            exec($command,$tmp_output, $retval);
                        }
                        if($retval == 0) {
                            // Now import backup-mailbox into special backup-folder
                            $backupname = "backup-".date("Y-m-d", $mail_backup['tstamp']);
                            exec("doveadm mailbox create -u \"".$record["email"]."\" $backupname");
                            exec("doveadm import -u \"".$record["email"]."\" mdbox:".$record['maildir']."/backup $backupname all", $tmp_output, $retval);
                            exec("for f in `doveadm mailbox list -u \"".$record["email"]."\" $backupname*`; do doveadm mailbox subscribe -u \"".$record["email"]."\" \$f; done", $tmp_output, $retval);
                            exec('rm -rf '.$record['maildir'].'/backup');
                        }
                        if($retval == 0){
                            $app->log('Restored Mail backup '.$mail_backup_file,LOGLEVEL_DEBUG);
                        } else {
                            // cleanup
                            if (file_exists($record['maildir'].'/'.$mail_backup['filename'])) unlink($record['maildir'].'/'.$mail_backup['filename']);
                            if (file_exists($record['maildir']."/backup")) exec('rm -rf '.$record['maildir']."/backup");
                            $app->log('Unable to restore Mail backup '.$mail_backup_file.' '.$tmp_output,LOGLEVEL_ERROR);
                        }
                    }
                    if($mail_backup['backup_mode'] == 'rootgz') {
                        $command='tar xfz '.escapeshellarg($mail_backup_file).' --directory '.escapeshellarg($domain_dir);
                        exec($command,$tmp_output, $retval);
                        if($retval == 0){
                            $app->log('Restored Mail backup '.$mail_backup_file,LOGLEVEL_DEBUG);
                        } else {
                            $app->log('Unable to restore Mail backup '.$mail_backup_file.' '.$tmp_output,LOGLEVEL_ERROR);
                    else {
                        if($mail_backup['backup_mode'] == 'userzip') {
                            copy($mail_backup_file, $domain_dir.'/'.$mail_backup['filename']);
                            chgrp($domain_dir.'/'.$mail_backup['filename'], $mail_config['mailuser_group']);
                            $command = 'sudo -u '.$mail_config['mailuser_name'].' unzip -qq -o  '.escapeshellarg($domain_dir.'/'.$mail_backup['filename']).' -d '.escapeshellarg($domain_dir).' 2> /dev/null';
                            exec($command,$tmp_output, $retval);
                            unlink($domain_dir.'/'.$mail_backup['filename']);
                            if($retval == 0){
                                $app->log('Restored Mail backup '.$mail_backup_file,LOGLEVEL_DEBUG);
                            } else {
                                $app->log('Unable to restore Mail backup '.$mail_backup_file.' '.$tmp_output,LOGLEVEL_ERROR);
                            }
                        }
                        if($mail_backup['backup_mode'] == 'rootgz') {
                            $command='tar xfz '.escapeshellarg($mail_backup_file).' --directory '.escapeshellarg($domain_dir);
                            exec($command,$tmp_output, $retval);
                            if($retval == 0){
                                $app->log('Restored Mail backup '.$mail_backup_file,LOGLEVEL_DEBUG);
                            } else {
                                $app->log('Unable to restore Mail backup '.$mail_backup_file.' '.$tmp_output,LOGLEVEL_ERROR);
                            }
                        }
                    }
                }
server/plugins-available/mail_plugin.inc.php
@@ -130,67 +130,80 @@
            $app->log('Created Directory: '.$base_path, LOGLEVEL_DEBUG);
        }
        // Dovecot uses a different mail layout with a separate 'Maildir' subdirectory.
        if($mail_config['pop3_imap_daemon'] == 'dovecot') {
            //exec("su -c 'mkdir -p ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
            $app->system->mkdirpath($maildomain_path, 0700, $user, $group);
            $app->log('Created Directory: '.$maildomain_path, LOGLEVEL_DEBUG);
            $maildomain_path .= '/Maildir';
        if ($data['new']['maildir_format'] == 'mdbox') {
            exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" INBOX'");
            exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Sent'");
            exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Trash'");
            exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Junk'");
            exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Drafts'");
            exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" INBOX'");
            exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Sent'");
            exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Trash'");
            exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Junk'");
            exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Drafts'");
        }
        //* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder
        if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
            if(!is_dir($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'])) $app->system->mkdirpath($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
            exec("su -c 'mv -f ".escapeshellcmd($data['new']['maildir'])." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id']."' vmail");
            $app->log('Moved invalid maildir to corrupted Maildirs folder: '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_WARN);
        }
        //* Create the maildir, if it doesn not exist, set permissions, set quota.
        if(!empty($maildomain_path) && !is_dir($maildomain_path)) {
            //exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
            $app->system->maildirmake($maildomain_path, $user, '', $group);
            //* This is to fix the maildrop quota not being rebuilt after the quota is changed.
            if($mail_config['pop3_imap_daemon'] != 'dovecot') {
                if(is_dir($maildomain_path)) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user); // Avoid maildirmake quota bug, see debian bug #214911
                $app->log('Created Maildir: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user, LOGLEVEL_DEBUG);
        else {
            // Dovecot uses a different mail layout with a separate 'Maildir' subdirectory.
            if($mail_config['pop3_imap_daemon'] == 'dovecot') {
                $app->system->mkdirpath($maildomain_path, 0700, $user, $group);
                $app->log('Created Directory: '.$maildomain_path, LOGLEVEL_DEBUG);
                $maildomain_path .= '/Maildir';
            }
            //* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder
            if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
                if(!is_dir($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'])) $app->system->mkdirpath($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
                exec("su -c 'mv -f ".escapeshellcmd($data['new']['maildir'])." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id']."' vmail");
                $app->log('Moved invalid maildir to corrupted Maildirs folder: '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_WARN);
            }
            //* Create the maildir, if it doesn not exist, set permissions, set quota.
            if(!empty($maildomain_path) && !is_dir($maildomain_path)) {
                //exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                $app->system->maildirmake($maildomain_path, $user, '', $group);
                //* This is to fix the maildrop quota not being rebuilt after the quota is changed.
                if($mail_config['pop3_imap_daemon'] != 'dovecot') {
                    if(is_dir($maildomain_path)) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user); // Avoid maildirmake quota bug, see debian bug #214911
                    $app->log('Created Maildir: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user, LOGLEVEL_DEBUG);
                }
            }
            if(!is_dir($data['new']['maildir'].'/.Sent')) {
                //exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                //$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
                $app->system->maildirmake($maildomain_path, $user, 'Sent', $group);
            }
            if(!is_dir($data['new']['maildir'].'/.Drafts')) {
                //exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                //$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
                $app->system->maildirmake($maildomain_path, $user, 'Drafts', $group);
            }
            if(!is_dir($data['new']['maildir'].'/.Trash')) {
                //exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                //$app->log('Created submaildir Trash: '."su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
                $app->system->maildirmake($maildomain_path, $user, 'Trash', $group);
            }
            if(!is_dir($data['new']['maildir'].'/.Junk')) {
                //exec("su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                //$app->log('Created submaildir Junk: '."su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
                $app->system->maildirmake($maildomain_path, $user, 'Junk', $group);
            }
            // Set permissions now recursive
            exec('chown -R '.$user.':'.$group.' '.escapeshellcmd($data['new']['maildir']));
            $app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_DEBUG);
            //* Set the maildir quota
            if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') {
                if($data['new']['quota'] > 0) {
                    if(is_dir($data['new']['maildir'])) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user);
                    $app->log('Set Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user, LOGLEVEL_DEBUG);
                }
            }
        }
        if(!is_dir($data['new']['maildir'].'/.Sent')) {
            //exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
            //$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
            $app->system->maildirmake($maildomain_path, $user, 'Sent', $group);
        }
        if(!is_dir($data['new']['maildir'].'/.Drafts')) {
            //exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
            //$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
            $app->system->maildirmake($maildomain_path, $user, 'Drafts', $group);
        }
        if(!is_dir($data['new']['maildir'].'/.Trash')) {
            //exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
            //$app->log('Created submaildir Trash: '."su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
            $app->system->maildirmake($maildomain_path, $user, 'Trash', $group);
        }
        if(!is_dir($data['new']['maildir'].'/.Junk')) {
            //exec("su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
            //$app->log('Created submaildir Junk: '."su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
            $app->system->maildirmake($maildomain_path, $user, 'Junk', $group);
        }
        // Set permissions now recursive
        exec('chown -R '.$user.':'.$group.' '.escapeshellcmd($data['new']['maildir']));
        $app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_DEBUG);
        //* Set the maildir quota
        if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') {
            if($data['new']['quota'] > 0) {
                if(is_dir($data['new']['maildir'])) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user);
                $app->log('Set Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user, LOGLEVEL_DEBUG);
            }
        }
        //* Send the welcome email message
        if(file_exists($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$conf['language'].'.txt')) {
@@ -252,6 +265,9 @@
        }
        */
        // Maildir-Format must not be changed on this way !!
        $data['new']['maildir_format'] = $data['old']['maildir_format'];
        $maildomain_path = $data['new']['maildir'];
        $tmp_basepath = $data['new']['maildir'];
        $tmp_basepath_parts = explode('/', $tmp_basepath);
@@ -296,84 +312,115 @@
            $app->log('Created Directory: '.$base_path, LOGLEVEL_DEBUG);
        }
        // Dovecot uses a different mail layout with a separate 'Maildir' subdirectory.
        if($mail_config['pop3_imap_daemon'] == 'dovecot') {
            $app->system->mkdirpath($maildomain_path, 0700, $user, $group);
            $app->log('Created Directory: '.$base_path, LOGLEVEL_DEBUG);
            $maildomain_path .= '/Maildir';
        if ($data['new']['maildir_format'] == 'mdbox') {
            // Move mailbox, if domain has changed and delete old mailbox
            if($data['new']['maildir'] != $data['old']['maildir'] && is_dir($data['old']['maildir'])) {
                if(is_dir($data['new']['maildir'])) {
                    exec("rm -fr ".escapeshellcmd($data['new']['maildir']));
                    //rmdir($data['new']['maildir']);
                }
                exec('mv -f '.escapeshellcmd($data['old']['maildir']).' '.escapeshellcmd($data['new']['maildir']));
                // exec('mv -f '.escapeshellcmd($data['old']['maildir']).'/* '.escapeshellcmd($data['new']['maildir']));
                // if(is_file($data['old']['maildir'].'.ispconfig_mailsize'))exec('mv -f '.escapeshellcmd($data['old']['maildir']).'.ispconfig_mailsize '.escapeshellcmd($data['new']['maildir']));
                // rmdir($data['old']['maildir']);
                $app->log('Moved Maildir from: '.$data['old']['maildir'].' to '.$data['new']['maildir'], LOGLEVEL_DEBUG);
            }
            //* Create the maildir, if it doesn not exist, set permissions, set quota.
            if(!is_dir($data['new']['maildir'].'/mdbox')) {
                exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" INBOX'");
                exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Sent'");
                exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Trash'");
                exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Junk'");
                exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Drafts'");
                exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" INBOX'");
                exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Sent'");
                exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Trash'");
                exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Junk'");
                exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Drafts'");
            }
        }
        //* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder
        if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
            if(!is_dir($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'])) $app->system->mkdirpath($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
            exec("su -c 'mv -f ".escapeshellcmd($data['new']['maildir'])." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id']."' vmail");
            $app->log('Moved invalid maildir to corrupted Maildirs folder: '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_WARN);
        }
        //* Create the maildir, if it doesn not exist, set permissions, set quota.
        if(!empty($maildomain_path) && !is_dir($maildomain_path.'/new')) {
            //exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
            //$app->log("Created Maildir "."su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
            $app->system->maildirmake($maildomain_path, $user, '', $group);
            //* This is to fix the maildrop quota not being rebuilt after the quota is changed.
            if($mail_config['pop3_imap_daemon'] != 'dovecot') {
        else {
            // Dovecot uses a different mail layout with a separate 'Maildir' subdirectory.
            if($mail_config['pop3_imap_daemon'] == 'dovecot') {
                $app->system->mkdirpath($maildomain_path, 0700, $user, $group);
                $app->log('Created Directory: '.$base_path, LOGLEVEL_DEBUG);
                $maildomain_path .= '/Maildir';
            }
            //* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder
            if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
                if(!is_dir($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'])) $app->system->mkdirpath($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
                exec("su -c 'mv -f ".escapeshellcmd($data['new']['maildir'])." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id']."' vmail");
                $app->log('Moved invalid maildir to corrupted Maildirs folder: '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_WARN);
            }
            //* Create the maildir, if it doesn not exist, set permissions, set quota.
            if(!empty($maildomain_path) && !is_dir($maildomain_path.'/new')) {
                //exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                //$app->log("Created Maildir "."su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
                $app->system->maildirmake($maildomain_path, $user, '', $group);
                //* This is to fix the maildrop quota not being rebuilt after the quota is changed.
                if($mail_config['pop3_imap_daemon'] != 'dovecot') {
                    if($data['new']['quota'] > 0) {
                        if(is_dir($maildomain_path)) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user); // Avoid maildirmake quota bug, see debian bug #214911
                        $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user, LOGLEVEL_DEBUG);
                    } else {
                        if(file_exists($data['new']['maildir'].'/maildirsize')) unlink($data['new']['maildir'].'/maildirsize');
                        $app->log('Set Maildir quota to unlimited.', LOGLEVEL_DEBUG);
                    }
                }
            }
            if(!is_dir($data['new']['maildir'].'/.Sent')) {
                //exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                //$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
                $app->system->maildirmake($maildomain_path, $user, 'Sent', $group);
            }
            if(!is_dir($data['new']['maildir'].'/.Drafts')) {
                //exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                //$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
                $app->system->maildirmake($maildomain_path, $user, 'Drafts', $group);
            }
            if(!is_dir($data['new']['maildir'].'/.Trash')) {
                //exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                //$app->log('Created submaildir Trash: '."su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
                $app->system->maildirmake($maildomain_path, $user, 'Trash', $group);
            }
            if(!is_dir($data['new']['maildir'].'/.Junk')) {
                //exec("su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
                //$app->log('Created submaildir Junk: '."su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
                $app->system->maildirmake($maildomain_path, $user, 'Junk', $group);
            }
            // Set permissions now recursive
            exec('chown -R '.$user.':'.$group.' '.escapeshellcmd($data['new']['maildir']));
            $app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_DEBUG);
            // Move mailbox, if domain has changed and delete old mailbox
            if($data['new']['maildir'] != $data['old']['maildir'] && is_dir($data['old']['maildir'])) {
                if(is_dir($data['new']['maildir'])) {
                    exec("rm -fr ".escapeshellcmd($data['new']['maildir']));
                    //rmdir($data['new']['maildir']);
                }
                exec('mv -f '.escapeshellcmd($data['old']['maildir']).' '.escapeshellcmd($data['new']['maildir']));
                // exec('mv -f '.escapeshellcmd($data['old']['maildir']).'/* '.escapeshellcmd($data['new']['maildir']));
                // if(is_file($data['old']['maildir'].'.ispconfig_mailsize'))exec('mv -f '.escapeshellcmd($data['old']['maildir']).'.ispconfig_mailsize '.escapeshellcmd($data['new']['maildir']));
                // rmdir($data['old']['maildir']);
                $app->log('Moved Maildir from: '.$data['old']['maildir'].' to '.$data['new']['maildir'], LOGLEVEL_DEBUG);
            }
            //This is to fix the maildrop quota not being rebuilt after the quota is changed.
            // Courier Layout
            if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') {
                if($data['new']['quota'] > 0) {
                    if(is_dir($maildomain_path)) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user); // Avoid maildirmake quota bug, see debian bug #214911
                    $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user, LOGLEVEL_DEBUG);
                    if(is_dir($data['new']['maildir'])) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user);
                    $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user, LOGLEVEL_DEBUG);
                } else {
                    if(file_exists($data['new']['maildir'].'/maildirsize')) unlink($data['new']['maildir'].'/maildirsize');
                    $app->log('Set Maildir quota to unlimited.', LOGLEVEL_DEBUG);
                }
            }
        }
        if(!is_dir($data['new']['maildir'].'/.Sent')) {
            //exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
            //$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
            $app->system->maildirmake($maildomain_path, $user, 'Sent', $group);
        }
        if(!is_dir($data['new']['maildir'].'/.Drafts')) {
            //exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
            //$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
            $app->system->maildirmake($maildomain_path, $user, 'Drafts', $group);
        }
        if(!is_dir($data['new']['maildir'].'/.Trash')) {
            //exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
            //$app->log('Created submaildir Trash: '."su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
            $app->system->maildirmake($maildomain_path, $user, 'Trash', $group);
        }
        if(!is_dir($data['new']['maildir'].'/.Junk')) {
            //exec("su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
            //$app->log('Created submaildir Junk: '."su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG);
            $app->system->maildirmake($maildomain_path, $user, 'Junk', $group);
        }
        // Set permissions now recursive
        exec('chown -R '.$user.':'.$group.' '.escapeshellcmd($data['new']['maildir']));
        $app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_DEBUG);
        // Move mailbox, if domain has changed and delete old mailbox
        if($data['new']['maildir'] != $data['old']['maildir'] && is_dir($data['old']['maildir'])) {
            if(is_dir($data['new']['maildir'])) {
                exec("rm -fr ".escapeshellcmd($data['new']['maildir']));
                //rmdir($data['new']['maildir']);
            }
            exec('mv -f '.escapeshellcmd($data['old']['maildir']).' '.escapeshellcmd($data['new']['maildir']));
            // exec('mv -f '.escapeshellcmd($data['old']['maildir']).'/* '.escapeshellcmd($data['new']['maildir']));
            // if(is_file($data['old']['maildir'].'.ispconfig_mailsize'))exec('mv -f '.escapeshellcmd($data['old']['maildir']).'.ispconfig_mailsize '.escapeshellcmd($data['new']['maildir']));
            // rmdir($data['old']['maildir']);
            $app->log('Moved Maildir from: '.$data['old']['maildir'].' to '.$data['new']['maildir'], LOGLEVEL_DEBUG);
        }
        //This is to fix the maildrop quota not being rebuilt after the quota is changed.
        // Courier Layout
        if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') {
            if($data['new']['quota'] > 0) {
                if(is_dir($data['new']['maildir'])) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user);
                $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user, LOGLEVEL_DEBUG);
            } else {
                if(file_exists($data['new']['maildir'].'/maildirsize')) unlink($data['new']['maildir'].'/maildirsize');
                $app->log('Set Maildir quota to unlimited.', LOGLEVEL_DEBUG);
            }
        }
    }