Dominik Müller
2014-01-18 0e2978ef48e7877ee46aa4a9e52e86b8f76c9733
Mailbox quota can now be included into website quota (FS#3297)
--------------------------------------------------------------
Feature can be activated over admin mailserver settings. when activated websites uid is used instead of standard vmail-uid. this only takes effect if web and mailserver are on the same server, otherwise it will be old behaviour. switching this setting when mailboxes exist doesn't matter. Mailboxfolder will be created with website uid for this. access of postfix and dovecot now works over mysql-table mail_user. virtual_uid_maps is changed from static to mysql-table. for dovecot<->postfix communication protocoll is changed vrom lda to lmtp. disablelmtp-column is added to mail_user-table. uid and gid can be overwritten by remoting.
ONE OPEN ISSUE: since remoting has completly changed and mail_user_add function is missing at the moment, this function now was inclulded again. it is important to add the both new lines to the future function and then remove this new one.
40 files modified
3 files added
328 ■■■■ changed files
install/sql/incremental/upd_0063.sql 1 ●●●● patch | view | raw | blame | history
install/sql/ispconfig3.sql 1 ●●●● patch | view | raw | blame | history
install/tpl/debian6_dovecot2.conf.master 13 ●●●●● patch | view | raw | blame | history
install/tpl/debian_dovecot2.conf.master 13 ●●●●● patch | view | raw | blame | history
install/tpl/debian_postfix.conf.master 6 ●●●● patch | view | raw | blame | history
install/tpl/fedora_dovecot2.conf.master 13 ●●●●● patch | view | raw | blame | history
install/tpl/fedora_postfix.conf.master 6 ●●●● patch | view | raw | blame | history
install/tpl/gentoo_postfix.conf.master 6 ●●●● patch | view | raw | blame | history
install/tpl/mysql-virtual_gids.cf.master 8 ●●●●● patch | view | raw | blame | history
install/tpl/mysql-virtual_uids.cf.master 8 ●●●●● patch | view | raw | blame | history
install/tpl/opensuse_dovecot2.conf.master 13 ●●●●● patch | view | raw | blame | history
install/tpl/opensuse_postfix.conf.master 6 ●●●● patch | view | raw | blame | history
install/tpl/server.ini.master 1 ●●●● patch | view | raw | blame | history
interface/lib/classes/remoting.inc.php 26 ●●●●● 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 8 ●●●●● patch | view | raw | blame | history
interface/web/themes/default-304/templates/admin/server_config_mail_edit.htm 6 ●●●●● patch | view | raw | blame | history
interface/web/themes/default-304/templates/mail/spamfilter_config_mail_edit.htm 6 ●●●●● patch | view | raw | blame | history
server/lib/classes/system.inc.php 66 ●●●● patch | view | raw | blame | history
server/plugins-available/mail_plugin.inc.php 92 ●●●● patch | view | raw | blame | history
install/sql/incremental/upd_0063.sql
New file
@@ -0,0 +1 @@
ALTER TABLE `mail_user` ADD `disablelmtp` ENUM( 'n', 'y' ) NOT NULL DEFAULT 'n' AFTER `disablelda` ;
install/sql/ispconfig3.sql
@@ -884,6 +884,7 @@
  `disablesmtp` enum('n','y') NOT NULL default 'n',
  `disablesieve` enum('n','y') NOT NULL default 'n',
  `disablelda` enum('n','y') NOT NULL default 'n',
  `disablelmtp` enum('n','y') NOT NULL default 'n',
  `disabledoveadm` enum('n','y') NOT NULL default 'n',
  `last_quota_notification` date NULL default NULL,
  `backup_interval` VARCHAR( 255 ) NOT NULL,
install/tpl/debian6_dovecot2.conf.master
@@ -1,5 +1,5 @@
listen = *,[::]
protocols = imap pop3
protocols = imap pop3 lmtp
auth_mechanisms = plain login
disable_plaintext_auth = no
log_timestamp = "%Y-%m-%d %H:%M:%S "
@@ -31,6 +31,13 @@
  }
  user = root
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
   group = postfix
   mode = 0600
   user = postfix
  }
}
service imap-login {
  client_limit = 1000
  process_limit = 500
@@ -44,4 +51,8 @@
}
protocol lda {
  mail_plugins = sieve quota
}
protocol lmtp {
  postmaster_address = webmaster@localhost
  mail_plugins = quota sieve
}
install/tpl/debian_dovecot2.conf.master
@@ -1,5 +1,5 @@
listen = *,[::]
protocols = imap pop3
protocols = imap pop3 lmtp
auth_mechanisms = plain login
disable_plaintext_auth = no
log_timestamp = "%Y-%m-%d %H:%M:%S "
@@ -31,6 +31,13 @@
  }
  user = root
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
   group = postfix
   mode = 0600
   user = postfix
  }
}
service imap-login {
  client_limit = 1000
  process_limit = 500
@@ -44,4 +51,8 @@
}
protocol lda {
  mail_plugins = sieve quota
}
protocol lmtp {
  postmaster_address = webmaster@localhost
  mail_plugins = quota sieve
}
install/tpl/debian_postfix.conf.master
@@ -5,8 +5,8 @@
virtual_mailbox_domains = proxy:mysql:{config_dir}/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:{config_dir}/mysql-virtual_mailboxes.cf
virtual_mailbox_base = {vmail_mailbox_base}
virtual_uid_maps = static:{vmail_userid}
virtual_gid_maps = static:{vmail_groupid}
virtual_uid_maps = mysql:/etc/postfix/mysql-virtual_uids.cf
virtual_gid_maps = mysql:/etc/postfix/mysql-virtual_gids.cf
inet_protocols=all
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
@@ -25,7 +25,7 @@
smtpd_client_message_rate_limit = 100
maildrop_destination_concurrency_limit = 1
maildrop_destination_recipient_limit   = 1
virtual_transport = maildrop
virtual_transport = lmtp:unix:private/dovecot-lmtp
header_checks = regexp:{config_dir}/header_checks
mime_header_checks = regexp:{config_dir}/mime_header_checks
nested_header_checks = regexp:{config_dir}/nested_header_checks
install/tpl/fedora_dovecot2.conf.master
@@ -1,5 +1,5 @@
listen = *,[::]
protocols = imap pop3
protocols = imap pop3 lmtp
auth_mechanisms = plain login
disable_plaintext_auth = no
log_timestamp = "%Y-%m-%d %H:%M:%S "
@@ -31,6 +31,13 @@
  }
  user = root
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
   group = postfix
   mode = 0600
   user = postfix
  }
}
service imap-login {
  client_limit = 1000
  process_limit = 500
@@ -44,4 +51,8 @@
}
protocol lda {
  mail_plugins = sieve quota
}
protocol lmtp {
  postmaster_address = webmaster@localhost
  mail_plugins = quota sieve
}
install/tpl/fedora_postfix.conf.master
@@ -3,8 +3,8 @@
virtual_mailbox_domains = proxy:mysql:{config_dir}/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:{config_dir}/mysql-virtual_mailboxes.cf
virtual_mailbox_base = {vmail_mailbox_base}
virtual_uid_maps = static:{vmail_userid}
virtual_gid_maps = static:{vmail_groupid}
virtual_uid_maps = mysql:/etc/postfix/mysql-virtual_uids.cf
virtual_gid_maps = mysql:/etc/postfix/mysql-virtual_gids.cf
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
@@ -22,7 +22,7 @@
smtpd_client_message_rate_limit = 100
maildrop_destination_concurrency_limit = 1
maildrop_destination_recipient_limit   = 1
virtual_transport = maildrop
virtual_transport = lmtp:unix:private/dovecot-lmtp
header_checks = regexp:{config_dir}/header_checks
mime_header_checks = regexp:{config_dir}/mime_header_checks
nested_header_checks = regexp:{config_dir}/nested_header_checks
install/tpl/gentoo_postfix.conf.master
@@ -3,8 +3,8 @@
virtual_mailbox_domains = proxy:mysql:{config_dir}/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:{config_dir}/mysql-virtual_mailboxes.cf
virtual_mailbox_base = {vmail_mailbox_base}
virtual_uid_maps = static:{vmail_userid}
virtual_gid_maps = static:{vmail_groupid}
virtual_uid_maps = mysql:/etc/postfix/mysql-virtual_uids.cf
virtual_gid_maps = mysql:/etc/postfix/mysql-virtual_gids.cf
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
@@ -22,7 +22,7 @@
smtpd_client_message_rate_limit = 100
maildrop_destination_concurrency_limit = 1
maildrop_destination_recipient_limit   = 1
virtual_transport = maildrop
virtual_transport = lmtp:unix:private/dovecot-lmtp
header_checks = regexp:{config_dir}/header_checks
mime_header_checks = regexp:{config_dir}/mime_header_checks
nested_header_checks = regexp:{config_dir}/nested_header_checks
install/tpl/mysql-virtual_gids.cf.master
New file
@@ -0,0 +1,8 @@
user = {mysql_server_ispconfig_user}
password = {mysql_server_ispconfig_password}
dbname = {mysql_server_database}
table = mail_user
select_field = gid
where_field = email
additional_conditions = and postfix = 'y' and server_id = {server_id}
hosts = {mysql_server_ip}
install/tpl/mysql-virtual_uids.cf.master
New file
@@ -0,0 +1,8 @@
user = {mysql_server_ispconfig_user}
password = {mysql_server_ispconfig_password}
dbname = {mysql_server_database}
table = mail_user
select_field = uid
where_field = email
additional_conditions = and postfix = 'y' and server_id = {server_id}
hosts = {mysql_server_ip}
install/tpl/opensuse_dovecot2.conf.master
@@ -1,5 +1,5 @@
listen = *,[::]
protocols = imap pop3
protocols = imap pop3 lmtp
auth_mechanisms = plain login
disable_plaintext_auth = no
log_timestamp = "%Y-%m-%d %H:%M:%S "
@@ -31,6 +31,13 @@
  }
  user = root
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
   group = postfix
   mode = 0600
   user = postfix
  }
}
service imap-login {
  client_limit = 1000
  process_limit = 500
@@ -44,4 +51,8 @@
}
protocol lda {
  mail_plugins = sieve quota
}
protocol lmtp {
  postmaster_address = webmaster@localhost
  mail_plugins = quota sieve
}
install/tpl/opensuse_postfix.conf.master
@@ -3,8 +3,8 @@
virtual_mailbox_domains = proxy:mysql:{config_dir}/mysql-virtual_domains.cf
virtual_mailbox_maps = proxy:mysql:{config_dir}/mysql-virtual_mailboxes.cf
virtual_mailbox_base = {vmail_mailbox_base}
virtual_uid_maps = static:{vmail_userid}
virtual_gid_maps = static:{vmail_groupid}
virtual_uid_maps = mysql:/etc/postfix/mysql-virtual_uids.cf
virtual_gid_maps = mysql:/etc/postfix/mysql-virtual_gids.cf
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
@@ -22,7 +22,7 @@
smtpd_client_message_rate_limit = 100
maildrop_destination_concurrency_limit = 1
maildrop_destination_recipient_limit   = 1
virtual_transport = maildrop
virtual_transport = lmtp:unix:private/dovecot-lmtp
header_checks = regexp:{config_dir}/header_checks
mime_header_checks = regexp:{config_dir}/mime_header_checks
nested_header_checks = regexp:{config_dir}/nested_header_checks
install/tpl/server.ini.master
@@ -38,6 +38,7 @@
mailuser_gid=5000
mailuser_name=vmail
mailuser_group=vmail
mailbox_virtual_uidgid_maps=n
relayhost=
relayhost_user=
relayhost_password=
interface/lib/classes/remoting.inc.php
@@ -184,7 +184,31 @@
        return $app->db->affectedRows() == 1;
    }
    //* Add mail domain
    public function mail_user_add($session_id, $client_id, $params){
        global $app;
        if (!$this->checkPerm($session_id, 'mail_user_add')){
            $this->server->fault('permission_denied','You do not have the permissions to access this function.');
            return false;
        }
        //* Check if mail domain exists
        $email_parts = explode('@',$params['email']);
        $tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = '".$app->db->quote($email_parts[1])."'");
        if($tmp['domain'] != $email_parts[1]) {
            $this->server->fault('mail_domain_does_not_exist','Mail domain - '.$email_parts[1].' - does not exist.');
            return false;
        }
        //* Set a few params to non empty values that will be overwritten by mail_plugin
        if (!isset($params['uid'])) $params['uid'] = 999989999;
        if (!isset($params['gid'])) $params['gid'] = 999989999;
        $affected_rows = $this->insertQuery('../mail/form/mail_user.tform.php', $client_id, $params);
        return $affected_rows;
    }
    //** protected functions -----------------------------------------------------------------------------------
interface/web/admin/lib/lang/ar_server_config.lng
@@ -24,6 +24,7 @@
$wb['mailuser_gid_txt'] = 'Mailuser GID';
$wb['mailuser_name_txt'] = 'Mailuser Name';
$wb['mailuser_group_txt'] = 'Mailuser Group';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Relayhost User';
$wb['relayhost_password_txt'] = 'Relayhost Password';
interface/web/admin/lib/lang/bg_server_config.lng
@@ -22,6 +22,7 @@
$wb['mailuser_gid_txt'] = 'Mailuser GID';
$wb['mailuser_name_txt'] = 'Mailuser Name';
$wb['mailuser_group_txt'] = 'Mailuser Group';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Relayhost User';
$wb['relayhost_password_txt'] = 'Relayhost Password';
interface/web/admin/lib/lang/br_server_config.lng
@@ -23,6 +23,7 @@
$wb['mailuser_gid_txt'] = 'GID usuário de email';
$wb['mailuser_name_txt'] = 'Nome usuário de email';
$wb['mailuser_group_txt'] = 'Grupo usuário de email';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Host Relay';
$wb['relayhost_user_txt'] = 'Usuário do Host Relay';
$wb['relayhost_password_txt'] = 'Senha do Host Relay';
interface/web/admin/lib/lang/cz_server_config.lng
@@ -24,6 +24,7 @@
$wb['mailuser_gid_txt'] = 'Mail uživatel GID';
$wb['mailuser_name_txt'] = 'Mail uživatel jméno';
$wb['mailuser_group_txt'] = 'Mail uživatel skupina';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Relayhost uživatel';
$wb['relayhost_password_txt'] = 'Relayhost heslo';
interface/web/admin/lib/lang/de_server_config.lng
@@ -25,6 +25,7 @@
$wb['mailuser_gid_txt'] = 'Mailbenutzer GID';
$wb['mailuser_name_txt'] = 'Mailbenutzer Name';
$wb['mailuser_group_txt'] = 'Mailbenutzer Gruppe';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Website Linux Uid für Mailboxen (nur wenn beides auf gleichem Server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Relayhost Benutzer';
$wb['relayhost_password_txt'] = 'Relayhost Passwort';
interface/web/admin/lib/lang/el_server_config.lng
@@ -24,6 +24,7 @@
$wb['mailuser_gid_txt'] = 'Mailuser GID';
$wb['mailuser_name_txt'] = 'Όνομα Mailuser';
$wb['mailuser_group_txt'] = 'Ομάδα Mailuser';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Χρήστης Relayhost';
$wb['relayhost_password_txt'] = 'Συνθηματικό Relayhost';
interface/web/admin/lib/lang/en_server_config.lng
@@ -36,6 +36,7 @@
$wb["mailuser_gid_txt"] = 'Mailuser GID';
$wb["mailuser_name_txt"] = 'Mailuser Name';
$wb["mailuser_group_txt"] = 'Mailuser Group';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb["relayhost_txt"] = 'Relayhost';
$wb["relayhost_user_txt"] = 'Relayhost User';
$wb["relayhost_password_txt"] = 'Relayhost Password';
interface/web/admin/lib/lang/es_server_config.lng
@@ -22,6 +22,7 @@
$wb['mailuser_gid_txt'] = 'GID usuario de correo';
$wb['mailuser_name_txt'] = 'Nombre del usuario de correo';
$wb['mailuser_group_txt'] = 'Grupo del usuario de correo';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Servidor de retransmisión';
$wb['relayhost_user_txt'] = 'Usuario de retransmisión';
$wb['relayhost_password_txt'] = 'Contraseña de retramisión';
interface/web/admin/lib/lang/fi_server_config.lng
@@ -22,6 +22,7 @@
$wb['mailuser_gid_txt'] = 'Käyttäjäryhmä';
$wb['mailuser_name_txt'] = 'Postikäyttäjän nimi';
$wb['mailuser_group_txt'] = 'Postikäyttäjän ryhmä';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Edelleenlähetyspalvelin';
$wb['relayhost_user_txt'] = 'Edelleenlähetyspalvelimen käyttäjätunnus';
$wb['relayhost_password_txt'] = 'Edelleenlähetyspalvelimen salasana';
interface/web/admin/lib/lang/fr_server_config.lng
@@ -24,6 +24,7 @@
$wb['mailuser_gid_txt'] = 'GID de l\'utilisateur mail';
$wb['mailuser_name_txt'] = 'Nom d\'utilisateur mail';
$wb['mailuser_group_txt'] = 'Groupe de l\'utilisateur mail';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Hôte de relais';
$wb['relayhost_user_txt'] = 'Utilisateur du relais';
$wb['relayhost_password_txt'] = 'Mot de passe du relais';
interface/web/admin/lib/lang/hr_server_config.lng
@@ -23,6 +23,7 @@
$wb['mailuser_gid_txt'] = 'Mailuser GID';
$wb['mailuser_name_txt'] = 'Mailuser ime';
$wb['mailuser_group_txt'] = 'Mailuser grupa';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Relayhost korisnik';
$wb['relayhost_password_txt'] = 'Relayhost šifra';
interface/web/admin/lib/lang/hu_server_config.lng
@@ -22,6 +22,7 @@
$wb['mailuser_gid_txt'] = 'Mailuser GID';
$wb['mailuser_name_txt'] = 'Mailuser Name';
$wb['mailuser_group_txt'] = 'Mailuser Group';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Relayhost User';
$wb['relayhost_password_txt'] = 'Relayhost Password';
interface/web/admin/lib/lang/id_server_config.lng
@@ -24,6 +24,7 @@
$wb['mailuser_gid_txt'] = 'GID Pengguna Mail';
$wb['mailuser_name_txt'] = 'Nama Pengguna Mail';
$wb['mailuser_group_txt'] = 'Grup Pengguna Mail';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Pengguna Relayhost';
$wb['relayhost_password_txt'] = 'Kata Sandi Relayhost';
interface/web/admin/lib/lang/it_server_config.lng
@@ -21,6 +21,7 @@
$wb['mailuser_gid_txt'] = 'Mailuser GID';
$wb['mailuser_name_txt'] = 'Mailuser Name';
$wb['mailuser_group_txt'] = 'Mailuser Group';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Relayhost User';
$wb['relayhost_password_txt'] = 'Relayhost Password';
interface/web/admin/lib/lang/ja_server_config.lng
@@ -24,6 +24,7 @@
$wb['mailuser_gid_txt'] = 'メールユーザーのGID';
$wb['mailuser_name_txt'] = 'メールユーザー名';
$wb['mailuser_group_txt'] = 'メールユーザーグループ';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'リレーホスト';
$wb['relayhost_user_txt'] = 'リレーホストユーザー';
$wb['relayhost_password_txt'] = 'リレーホストパスワード';
interface/web/admin/lib/lang/nl_server_config.lng
@@ -24,6 +24,7 @@
$wb['mailuser_gid_txt'] = 'Mailuser GID';
$wb['mailuser_name_txt'] = 'Mailuser name';
$wb['mailuser_group_txt'] = 'Mailuser groep';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Relayhost gebruiker';
$wb['relayhost_password_txt'] = 'Relayhost wachtwoord';
interface/web/admin/lib/lang/pl_server_config.lng
@@ -24,6 +24,7 @@
$wb['mailuser_gid_txt'] = 'GID użytkownika e-mail';
$wb['mailuser_name_txt'] = 'Nazwa użytkownika e-mail';
$wb['mailuser_group_txt'] = 'Grupa użytkownika e-mail';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Adres Relayhost';
$wb['relayhost_user_txt'] = 'Użytkownik Relayhost';
$wb['relayhost_password_txt'] = 'Hasło Relayhost';
interface/web/admin/lib/lang/pt_server_config.lng
@@ -23,6 +23,7 @@
$wb['mailuser_gid_txt'] = 'GID utilizador de email';
$wb['mailuser_name_txt'] = 'Nome utilizador de email';
$wb['mailuser_group_txt'] = 'Grupo utilizador de email';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Host Relay';
$wb['relayhost_user_txt'] = 'Utilizador do Host Relay';
$wb['relayhost_password_txt'] = 'Senha do Host Relay';
interface/web/admin/lib/lang/ro_server_config.lng
@@ -23,6 +23,7 @@
$wb['mailuser_gid_txt'] = 'Mailuser GID';
$wb['mailuser_name_txt'] = 'Mailuser Name';
$wb['mailuser_group_txt'] = 'Mailuser Group';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Relayhost User';
$wb['relayhost_password_txt'] = 'Relayhost Password';
interface/web/admin/lib/lang/ru_server_config.lng
@@ -21,6 +21,7 @@
$wb['mailuser_gid_txt'] = 'Mailuser GID';
$wb['mailuser_name_txt'] = 'Имя Mailuser';
$wb['mailuser_group_txt'] = 'Группа Mailuser';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relay-хост';
$wb['relayhost_user_txt'] = 'Логин Relay-хоста';
$wb['relayhost_password_txt'] = 'Пароль Relay-хоста';
interface/web/admin/lib/lang/se_server_config.lng
@@ -22,6 +22,7 @@
$wb['mailuser_gid_txt'] = 'Mailuser GID';
$wb['mailuser_name_txt'] = 'Mailuser Name';
$wb['mailuser_group_txt'] = 'Mailuser Group';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Relayhost User';
$wb['relayhost_password_txt'] = 'Relayhost Password';
interface/web/admin/lib/lang/sk_server_config.lng
@@ -24,6 +24,7 @@
$wb['mailuser_gid_txt'] = 'Mailuser GID';
$wb['mailuser_name_txt'] = 'Mailuser Meno';
$wb['mailuser_group_txt'] = 'Mailuser Skupina';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Relayhost uživateľ';
$wb['relayhost_password_txt'] = 'Relayhost heslo';
interface/web/admin/lib/lang/tr_server_config.lng
@@ -24,6 +24,7 @@
$wb['mailuser_gid_txt'] = 'Mail kullanıcısı GID';
$wb['mailuser_name_txt'] = 'Mail kullanıcısı Adı';
$wb['mailuser_group_txt'] = 'Mail kullanıcısı Grubu';
$wb['mailbox_virtual_uidgid_maps_txt'] = 'Use Websites Linux uid for mailbox (only if both on the same server)';
$wb['relayhost_txt'] = 'Relayhost';
$wb['relayhost_user_txt'] = 'Relayhost Kullanıcı';
$wb['relayhost_password_txt'] = 'Relayhost Şifre';
interface/web/admin/templates/server_config_mail_edit.htm
@@ -56,6 +56,12 @@
                <input name="mailuser_group" id="mailuser_group" value="{tmpl_var name='mailuser_group'}" size="10" maxlength="255" type="text" class="textInput formLengthHalf" />
            </div>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='mailbox_virtual_uidgid_maps_txt'}</p>
                <div class="multiField">
                    {tmpl_var name='mailbox_virtual_uidgid_maps'}
                </div>
            </div>
            <div class="ctrlHolder">
                <label for="relayhost">{tmpl_var name='relayhost_txt'}</label>
                <input name="relayhost" id="relayhost" value="{tmpl_var name='relayhost'}" size="40" maxlength="255" type="text" class="textInput formLengthHalf" />
            </div>
interface/web/mail/mail_user_edit.php
@@ -203,9 +203,11 @@
            $maildir = str_replace("[localpart]", strtolower($_POST["email_local_part"]), $maildir);
            $this->dataRecord["maildir"] = $maildir;
            $this->dataRecord["homedir"] = $mail_config["homedir_path"];
            $this->dataRecord["uid"] = $mail_config["mailuser_uid"];
            $this->dataRecord["gid"] = $mail_config["mailuser_gid"];
            // Will be overwritten by mail_plugin
            $this->dataRecord['uid'] = 999989999;
            $this->dataRecord['gid'] = 999989999;
            //* Check if there is no alias or forward with this address
            $tmp = $app->db->queryOneRecord("SELECT count(forwarding_id) as number FROM mail_forwarding WHERE active = 'y' AND source = '".$app->db->quote($this->dataRecord["email"])."'");
            if($tmp['number'] > 0) $app->tform->errorMessage .= $app->tform->lng("duplicate_alias_or_forward_txt")."<br>";
interface/web/themes/default-304/templates/admin/server_config_mail_edit.htm
@@ -52,6 +52,12 @@
                <input name="mailuser_group" id="mailuser_group" value="{tmpl_var name='mailuser_group'}" size="10" maxlength="255" type="text" class="textInput formLengthHalf" />
            </div>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='mailbox_virtual_uidgid_maps_txt'}</p>
                <div class="multiField">
                    {tmpl_var name='mailbox_virtual_uidgid_maps'}
                </div>
            </div>
            <div class="ctrlHolder">
                <label for="relayhost">{tmpl_var name='relayhost_txt'}</label>
                <input name="relayhost" id="relayhost" value="{tmpl_var name='relayhost'}" size="40" maxlength="255" type="text" class="textInput formLengthHalf" />
            </div>
interface/web/themes/default-304/templates/mail/spamfilter_config_mail_edit.htm
@@ -33,6 +33,12 @@
                <label for="mailuser_group" class="wf_preField">{tmpl_var name='mailuser_group_txt'}</label>
                <input type="text" id="mailuser_group" name="mailuser_group" value="{tmpl_var name='mailuser_group'}" size="10" maxlength="255">
            </span>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='mailbox_virtual_uidgid_maps_txt'}</p>
                <div class="multiField">
                    {tmpl_var name='mailbox_virtual_uidgid_maps'}
                </div>
            </div>
            <span class="wf_oneField">
                <label for="relayhost" class="wf_preField">{tmpl_var name='relayhost_txt'}</label>
                <input type="text" id="relayhost" name="relayhost" value="{tmpl_var name='relayhost'}" size="40" maxlength="255">
server/lib/classes/system.inc.php
@@ -606,6 +606,30 @@
    /**
     * Get the user from an user id
     *
     */
    function getuser($uid){
        global $app;
        $user_datei = $this->server_conf['passwd_datei'];
        $users = $app->file->no_comments($user_datei);
        $lines = explode("\n", $users);
        if(is_array($lines)){
            foreach($lines as $line){
                if(trim($line) != ''){
                    list($f1, $f2, $f3,) = explode(':', $line);
                    if($f3 == $uid) return $f1;
                }
            }
        }
        return false;
    }
    /**
     * Get the user id from an user
     *
     */
@@ -626,6 +650,30 @@
        } else {
            return false;
        }
    }
    /**
     * Get the group from a group id
     *
     */
    function getgroup($gid){
        global $app;
        $group_datei = $this->server_conf['group_datei'];
        $groups = $app->file->no_comments($group_datei);
        $lines = explode("\n", $groups);
        if(is_array($lines)){
            foreach($lines as $line){
                if(trim($line) != ""){
                    list($f1, $f2, $f3, $f4) = explode(':', $line);
                    if($f3 == $gid) return $f1;
                }
            }
        }
        return false;
    }
@@ -1476,7 +1524,7 @@
        }
    }
    function maildirmake($maildir_path, $user = '', $subfolder = '') {
    function maildirmake($maildir_path, $user = '', $group = '', $subfolder = '') {
        global $app;
@@ -1490,22 +1538,24 @@
        if($user != '' && $user != 'root' && $this->is_user($user)) {
            $user = escapeshellcmd($user);
            // I assume that the name of the (vmail group) is the same as the name of the mail user in ISPConfig 3
            $group = $user;
            if(is_dir($dir)) $this->chown($dir, $user);
            if(is_dir($dir)) $this->chgrp($dir, $group);
            $chown_mdsub = true;
        }
        if($group != '' && $group != 'root' && $this->is_group($group)) {
            $group = escapeshellcmd($group);
            if(is_dir($dir)) $this->chgrp($dir, $group);
            $chgrp_mdsub = true;
        }
        $maildirsubs = array('cur', 'new', 'tmp');
        foreach ($maildirsubs as $mdsub) {
            if(!is_dir($dir.'/'.$mdsub)) mkdir($dir.'/'.$mdsub, 0700, true);
            if ($chown_mdsub) {
                chown($dir.'/'.$mdsub, $user);
                chgrp($dir.'/'.$mdsub, $group);
            }
            if ($chown_mdsub) chown($dir.'/'.$mdsub, $user);
            if ($chgrp_mdsub) chgrp($dir.'/'.$mdsub, $group);
        }
        chmod($dir, 0700);
server/plugins-available/mail_plugin.inc.php
@@ -92,17 +92,48 @@
        unset($tmp_basepath_parts[count($tmp_basepath_parts)-1]);
        $base_path = implode('/', $tmp_basepath_parts);
        //* Set the email-uid and gid if not given
        if (($data['new']['uid'] == 999989999) || ($data['new']['gid'] == 999989999)) {
            $app->log('Setting uid and gid automatically',LOGLEVEL_DEBUG);
            if ($mail_config["mailbox_virtual_uidgid_maps"] == 'y') {
                $app->log('Map uid to linux-user',LOGLEVEL_DEBUG);
                $email_parts = explode('@',$data['new']['email']);
                $webdomain = $app->db->queryOneRecord("SELECT domain_id, server_id, system_user, parent_domain_id FROM web_domain WHERE domain = '".$app->db->quote($email_parts[1])."'");
                if ($webdomain) {
                    while ($webdomain['parent_domain_id'] != 0) {
                        $webdomain = $app->db->queryOneRecord("SELECT domain_id, server_id, system_user, parent_domain_id FROM web_domain WHERE domain_id = '".$webdomain['parent_domain_id']."'");
                    }
                    $app->log($data['new']['server_id'].' == '.$webdomain['server_id'],LOGLEVEL_DEBUG);
                    // only if web and mailserver are identical
                    if ($data['new']['server_id'] == $webdomain['server_id']) {
                        $data['new']['uid'] = $app->system->getuid($webdomain['system_user']);
                    }
                }
            }
        }
        // if nothing set before -> use standard mailuser uid and gid vmail
        if ($data['new']['uid'] == 999989999) $data['new']['uid'] = $mail_config["mailuser_uid"];
        if ($data['new']['gid'] == 999989999) $data['new']['gid'] = $mail_config["mailuser_gid"];
        $app->log('Mailuser uid: '.$data['new']['uid'].', gid: '.$data['new']['gid'],LOGLEVEL_DEBUG);
        // update DB if values changed
        $app->db->query("UPDATE mail_user SET uid = ".$data['new']['uid'].", gid = ".$data['new']['gid']." WHERE mailuser_id = ".$data['new']['mailuser_id']);
        // now get names of uid and gid
        $user = $app->system->getuser($data['new']['uid']);
        $group = $app->system->getgroup($data['new']['gid']);
        //* Create the mail domain directory, if it does not exist
        if(!empty($base_path) && !is_dir($base_path)) {
            //exec("su -c 'mkdir -p ".escapeshellcmd($base_path)."' ".$mail_config['mailuser_name']);
            $app->system->mkdirpath($base_path, 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
            $app->system->mkdirpath($base_path, 0770, $mail_config['mailuser_name'], $mail_config['mailuser_group']); // needs group-access because users of subfolders may differ from vmail
            $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, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
            $app->system->mkdirpath($maildomain_path, 0700, $user, $group);
            $app->log('Created Directory: '.$maildomain_path, LOGLEVEL_DEBUG);
            $maildomain_path .= '/Maildir';
        }
@@ -117,46 +148,48 @@
        if(!empty($maildomain_path) && !is_dir($maildomain_path)) {
            //exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
            $app->system->maildirmake($maildomain_path, $mail_config['mailuser_name']);
            exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
            $app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']), 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(is_dir($maildomain_path)) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); // Avoid maildirmake quota bug, see debian bug #214911
                $app->log('Created Maildir: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'], LOGLEVEL_DEBUG);
                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, $mail_config['mailuser_name'], 'Sent');
            $app->system->maildirmake($maildomain_path, $user, $group, 'Sent');
        }
        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, $mail_config['mailuser_name'], 'Drafts');
            $app->system->maildirmake($maildomain_path, $user, $group, 'Drafts');
        }
        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, $mail_config['mailuser_name'], 'Trash');
            $app->system->maildirmake($maildomain_path, $user, $group, 'Trash');
        }
        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, $mail_config['mailuser_name'], 'Junk');
            $app->system->maildirmake($maildomain_path, $user, $group, 'Junk');
        }
        // 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'])."' ".$mail_config['mailuser_name']);
                $app->log('Set Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name'], LOGLEVEL_DEBUG);
                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')) {
@@ -224,16 +257,19 @@
        unset($tmp_basepath_parts[count($tmp_basepath_parts)-1]);
        $base_path = implode('/', $tmp_basepath_parts);
        $user = $app->system->getuser($data['new']['uid']);
        $group = $app->system->getgroup($data['new']['gid']);
        //* Create the mail domain directory, if it does not exist
        if(!empty($base_path) && !is_dir($base_path)) {
            //exec("su -c 'mkdir -p ".escapeshellcmd($base_path)."' ".$mail_config['mailuser_name']);
            $app->system->mkdirpath($base_path, 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
            $app->system->mkdirpath($base_path, 0770, $mail_config['mailuser_name'], $mail_config['mailuser_group']); // needs group-access because users of subfolders may differ from vmail
            $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, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
            $app->system->mkdirpath($maildomain_path, 0700, $user, $group);
            $app->log('Created Directory: '.$base_path, LOGLEVEL_DEBUG);
            $maildomain_path .= '/Maildir';
        }
@@ -248,15 +284,13 @@
        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, $mail_config['mailuser_name']);
            $app->system->maildirmake($maildomain_path, $user, $group);
            exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
            $app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_DEBUG);
            //* 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)."' ".$mail_config['mailuser_name']); // Avoid maildirmake quota bug, see debian bug #214911
                    $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'], LOGLEVEL_DEBUG);
                    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);
@@ -267,23 +301,27 @@
        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, $mail_config['mailuser_name'], 'Sent');
            $app->system->maildirmake($maildomain_path, $user, $group, 'Sent');
        }
        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, $mail_config['mailuser_name'], 'Drafts');
            $app->system->maildirmake($maildomain_path, $user, $group, 'Drafts');
        }
        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, $mail_config['mailuser_name'], 'Trash');
            $app->system->maildirmake($maildomain_path, $user, $group, 'Trash');
        }
        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, $mail_config['mailuser_name'], 'Junk');
            $app->system->maildirmake($maildomain_path, $user, $group, 'Junk');
        }
        // 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'])) {
@@ -301,8 +339,8 @@
        // 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'])."' ".$mail_config['mailuser_name']);
                $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$mail_config['mailuser_name'], 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);