diff --git a/install/sql/incremental/upd_0063.sql b/install/sql/incremental/upd_0063.sql new file mode 100644 index 0000000000000000000000000000000000000000..827fdee11a9d20a19d2695e67a14aa5b4604ba10 --- /dev/null +++ b/install/sql/incremental/upd_0063.sql @@ -0,0 +1 @@ +ALTER TABLE `mail_user` ADD `disablelmtp` ENUM( 'n', 'y' ) NOT NULL DEFAULT 'n' AFTER `disablelda` ; \ No newline at end of file diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 533151bbbf4974279c884d7594a096f48d9bb875..4841b1a726386295a58f090b4521195182b8ad73 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -884,6 +884,7 @@ CREATE TABLE `mail_user` ( `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, diff --git a/install/tpl/debian6_dovecot2.conf.master b/install/tpl/debian6_dovecot2.conf.master index f359260dabc47496f301110c4e20022db46c9a96..5b04c61a45163c443df75b7fcadd09396cb7b79e 100644 --- a/install/tpl/debian6_dovecot2.conf.master +++ b/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 @@ service auth { } 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 pop3 { } protocol lda { mail_plugins = sieve quota +} +protocol lmtp { + postmaster_address = webmaster@localhost + mail_plugins = quota sieve } \ No newline at end of file diff --git a/install/tpl/debian_dovecot2.conf.master b/install/tpl/debian_dovecot2.conf.master index f359260dabc47496f301110c4e20022db46c9a96..5b04c61a45163c443df75b7fcadd09396cb7b79e 100644 --- a/install/tpl/debian_dovecot2.conf.master +++ b/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 @@ service auth { } 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 pop3 { } protocol lda { mail_plugins = sieve quota +} +protocol lmtp { + postmaster_address = webmaster@localhost + mail_plugins = quota sieve } \ No newline at end of file diff --git a/install/tpl/debian_postfix.conf.master b/install/tpl/debian_postfix.conf.master index e5564c84ee6983cc4a8ba5bb2aee3300b81b4614..e8f3d82549f13027b627f3aea8332f4801be9e73 100644 --- a/install/tpl/debian_postfix.conf.master +++ b/install/tpl/debian_postfix.conf.master @@ -5,8 +5,8 @@ virtual_alias_maps = proxy:mysql:{config_dir}/mysql-virtual_forwardings.cf, prox 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_restrictions = check_client_access mysql:{config_dir}/mysql-virtual 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 diff --git a/install/tpl/fedora_dovecot2.conf.master b/install/tpl/fedora_dovecot2.conf.master index 75fad4fc76070aadf82b50dbd060e9e4a3d6f5b2..0d91006dda7fcc79e1c23beeb0e77b14581a5b6a 100644 --- a/install/tpl/fedora_dovecot2.conf.master +++ b/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 @@ service auth { } 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 pop3 { } protocol lda { mail_plugins = sieve quota +} +protocol lmtp { + postmaster_address = webmaster@localhost + mail_plugins = quota sieve } \ No newline at end of file diff --git a/install/tpl/fedora_postfix.conf.master b/install/tpl/fedora_postfix.conf.master index 35c3cac13c7ecbf0fe8a9681cf01afc95ad4d826..4401f706e0d43c6e3a3460be1a4b5b034eeb93df 100644 --- a/install/tpl/fedora_postfix.conf.master +++ b/install/tpl/fedora_postfix.conf.master @@ -3,8 +3,8 @@ virtual_alias_maps = proxy:mysql:{config_dir}/mysql-virtual_forwardings.cf, prox 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_restrictions = check_client_access mysql:{config_dir}/mysql-virtual 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 diff --git a/install/tpl/gentoo_postfix.conf.master b/install/tpl/gentoo_postfix.conf.master index 35c3cac13c7ecbf0fe8a9681cf01afc95ad4d826..4401f706e0d43c6e3a3460be1a4b5b034eeb93df 100644 --- a/install/tpl/gentoo_postfix.conf.master +++ b/install/tpl/gentoo_postfix.conf.master @@ -3,8 +3,8 @@ virtual_alias_maps = proxy:mysql:{config_dir}/mysql-virtual_forwardings.cf, prox 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_restrictions = check_client_access mysql:{config_dir}/mysql-virtual 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 diff --git a/install/tpl/mysql-virtual_gids.cf.master b/install/tpl/mysql-virtual_gids.cf.master new file mode 100644 index 0000000000000000000000000000000000000000..7c7d995fc98bb334e087f3a0e307a793f8cc1b9b --- /dev/null +++ b/install/tpl/mysql-virtual_gids.cf.master @@ -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} \ No newline at end of file diff --git a/install/tpl/mysql-virtual_uids.cf.master b/install/tpl/mysql-virtual_uids.cf.master new file mode 100644 index 0000000000000000000000000000000000000000..da3cd7c2a0936dc181a478d568a12a3a7aed7347 --- /dev/null +++ b/install/tpl/mysql-virtual_uids.cf.master @@ -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} diff --git a/install/tpl/opensuse_dovecot2.conf.master b/install/tpl/opensuse_dovecot2.conf.master index f359260dabc47496f301110c4e20022db46c9a96..5b04c61a45163c443df75b7fcadd09396cb7b79e 100644 --- a/install/tpl/opensuse_dovecot2.conf.master +++ b/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 @@ service auth { } 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 pop3 { } protocol lda { mail_plugins = sieve quota +} +protocol lmtp { + postmaster_address = webmaster@localhost + mail_plugins = quota sieve } \ No newline at end of file diff --git a/install/tpl/opensuse_postfix.conf.master b/install/tpl/opensuse_postfix.conf.master index 35c3cac13c7ecbf0fe8a9681cf01afc95ad4d826..4401f706e0d43c6e3a3460be1a4b5b034eeb93df 100644 --- a/install/tpl/opensuse_postfix.conf.master +++ b/install/tpl/opensuse_postfix.conf.master @@ -3,8 +3,8 @@ virtual_alias_maps = proxy:mysql:{config_dir}/mysql-virtual_forwardings.cf, prox 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_restrictions = check_client_access mysql:{config_dir}/mysql-virtual 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 diff --git a/install/tpl/server.ini.master b/install/tpl/server.ini.master index 9186cc18af857829afc26287e185ef9459e0b599..0d578e1582803cc2f9fe4c6f00b5ddeef3d11a4b 100644 --- a/install/tpl/server.ini.master +++ b/install/tpl/server.ini.master @@ -38,6 +38,7 @@ mailuser_uid=5000 mailuser_gid=5000 mailuser_name=vmail mailuser_group=vmail +mailbox_virtual_uidgid_maps=n relayhost= relayhost_user= relayhost_password= diff --git a/interface/lib/classes/remoting.inc.php b/interface/lib/classes/remoting.inc.php index 2dd717986f7066fa3b8cca23fae4a04c063aa5df..268b257bc4be6cccfa1f20302b767adcb3ef0454 100644 --- a/interface/lib/classes/remoting.inc.php +++ b/interface/lib/classes/remoting.inc.php @@ -184,7 +184,31 @@ class remoting { 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 ----------------------------------------------------------------------------------- diff --git a/interface/web/admin/lib/lang/ar_server_config.lng b/interface/web/admin/lib/lang/ar_server_config.lng index 1c21551a82bcaa7b066b1c885ee1a09d8892710b..26e13b40a7ee69760e96d83dcf8e12eedf4e40b8 100644 --- a/interface/web/admin/lib/lang/ar_server_config.lng +++ b/interface/web/admin/lib/lang/ar_server_config.lng @@ -24,6 +24,7 @@ $wb['mailuser_uid_txt'] = 'Mailuser UID'; $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'; diff --git a/interface/web/admin/lib/lang/bg_server_config.lng b/interface/web/admin/lib/lang/bg_server_config.lng index c050aad0298fea158f53c7824890f43b87b02f0f..db043eea8584d7fbc89cbd821dbcd5e86d957b91 100644 --- a/interface/web/admin/lib/lang/bg_server_config.lng +++ b/interface/web/admin/lib/lang/bg_server_config.lng @@ -22,6 +22,7 @@ $wb['mailuser_uid_txt'] = 'Mailuser UID'; $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'; diff --git a/interface/web/admin/lib/lang/br_server_config.lng b/interface/web/admin/lib/lang/br_server_config.lng index 71288a9aa0fde1e4c73c53c542eb2a9dc549e56a..67e8a20ec653313822e294cefccf456035ef88c5 100644 --- a/interface/web/admin/lib/lang/br_server_config.lng +++ b/interface/web/admin/lib/lang/br_server_config.lng @@ -23,6 +23,7 @@ $wb['mailuser_uid_txt'] = 'UID usuário de email'; $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'; diff --git a/interface/web/admin/lib/lang/cz_server_config.lng b/interface/web/admin/lib/lang/cz_server_config.lng index 18e833e31a76bd6b3ef5b387ebcbd8ec4dc4fdbc..a6601710958d7c096d8179821368580ba27f699a 100644 --- a/interface/web/admin/lib/lang/cz_server_config.lng +++ b/interface/web/admin/lib/lang/cz_server_config.lng @@ -24,6 +24,7 @@ $wb['mailuser_uid_txt'] = 'Mail uživatel UID'; $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'; diff --git a/interface/web/admin/lib/lang/de_server_config.lng b/interface/web/admin/lib/lang/de_server_config.lng index 5f615cc7f8042c7eb13335458e7ecb801b395496..c9673b2804b8eeb20cc8590d30a449651e46148d 100644 --- a/interface/web/admin/lib/lang/de_server_config.lng +++ b/interface/web/admin/lib/lang/de_server_config.lng @@ -25,6 +25,7 @@ $wb['mailuser_uid_txt'] = 'Mailbenutzer UID'; $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'; diff --git a/interface/web/admin/lib/lang/el_server_config.lng b/interface/web/admin/lib/lang/el_server_config.lng index 169a5608d8eed4358157201094a7e8805410a91a..407bc72c5f0a8f31ffe1b755e6b9ae928c09e04b 100644 --- a/interface/web/admin/lib/lang/el_server_config.lng +++ b/interface/web/admin/lib/lang/el_server_config.lng @@ -24,6 +24,7 @@ $wb['mailuser_uid_txt'] = 'Mailuser UID'; $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'; diff --git a/interface/web/admin/lib/lang/en_server_config.lng b/interface/web/admin/lib/lang/en_server_config.lng index 07e94af875a1d97c685846ecc1f62b32bb57edbd..e472859b12896b791e6ed03789e2dc37e410583e 100644 --- a/interface/web/admin/lib/lang/en_server_config.lng +++ b/interface/web/admin/lib/lang/en_server_config.lng @@ -36,6 +36,7 @@ $wb["mailuser_uid_txt"] = 'Mailuser UID'; $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'; diff --git a/interface/web/admin/lib/lang/es_server_config.lng b/interface/web/admin/lib/lang/es_server_config.lng index 1987c5145e729c2458d3db3ff8166b830e3a59a1..2088dba09ff36ddb368598f48e6fb5e2b4e59f3d 100644 --- a/interface/web/admin/lib/lang/es_server_config.lng +++ b/interface/web/admin/lib/lang/es_server_config.lng @@ -22,6 +22,7 @@ $wb['mailuser_uid_txt'] = 'UID usuario de correo'; $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'; diff --git a/interface/web/admin/lib/lang/fi_server_config.lng b/interface/web/admin/lib/lang/fi_server_config.lng index efa122033c8a22c75675bb5c2caaaf377f186a79..fe203bea32cbde7f1ed8b5c5ffe7a3b5cbc91e97 100755 --- a/interface/web/admin/lib/lang/fi_server_config.lng +++ b/interface/web/admin/lib/lang/fi_server_config.lng @@ -22,6 +22,7 @@ $wb['mailuser_uid_txt'] = 'Käyttäjätunnus'; $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'; diff --git a/interface/web/admin/lib/lang/fr_server_config.lng b/interface/web/admin/lib/lang/fr_server_config.lng index 32779c783ad81112aac53b0896c002536f26a166..f61a4096a1e762dd9292f170cabdb947fea51d41 100644 --- a/interface/web/admin/lib/lang/fr_server_config.lng +++ b/interface/web/admin/lib/lang/fr_server_config.lng @@ -24,6 +24,7 @@ $wb['mailuser_uid_txt'] = 'UID de l\'utilisateur mail'; $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'; diff --git a/interface/web/admin/lib/lang/hr_server_config.lng b/interface/web/admin/lib/lang/hr_server_config.lng index a441f968ade3df8d3657640581bd0954cc67a9eb..d7880eecb4af3c1ddf73071a58385d229546e287 100644 --- a/interface/web/admin/lib/lang/hr_server_config.lng +++ b/interface/web/admin/lib/lang/hr_server_config.lng @@ -23,6 +23,7 @@ $wb['mailuser_uid_txt'] = 'Mailuser UID'; $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'; diff --git a/interface/web/admin/lib/lang/hu_server_config.lng b/interface/web/admin/lib/lang/hu_server_config.lng index 0be61efd12652147da16ba0948338ba905abedc9..db881852ad961946f77ed3be817d8dbdcb327aa8 100644 --- a/interface/web/admin/lib/lang/hu_server_config.lng +++ b/interface/web/admin/lib/lang/hu_server_config.lng @@ -22,6 +22,7 @@ $wb['mailuser_uid_txt'] = 'Mailuser UID'; $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'; diff --git a/interface/web/admin/lib/lang/id_server_config.lng b/interface/web/admin/lib/lang/id_server_config.lng index 54a4493226e8c1580c076732c522e986d2445a29..dfa67f9ea7fafd92764d577750adf2a187d6eddb 100644 --- a/interface/web/admin/lib/lang/id_server_config.lng +++ b/interface/web/admin/lib/lang/id_server_config.lng @@ -24,6 +24,7 @@ $wb['mailuser_uid_txt'] = 'UID Pengguna Mail'; $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'; diff --git a/interface/web/admin/lib/lang/it_server_config.lng b/interface/web/admin/lib/lang/it_server_config.lng index d04076804781aef0e8be0ac067a03330eebe3ab1..33101e9717bf5a716531272a48e947aa8a638384 100644 --- a/interface/web/admin/lib/lang/it_server_config.lng +++ b/interface/web/admin/lib/lang/it_server_config.lng @@ -21,6 +21,7 @@ $wb['mailuser_uid_txt'] = 'Mailuser UID'; $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'; diff --git a/interface/web/admin/lib/lang/ja_server_config.lng b/interface/web/admin/lib/lang/ja_server_config.lng index 890bb568b98fcc3058fdbb8550fce1ed78f85246..46e8b21b7c5a930279e50246a0d87338d6f4677b 100644 --- a/interface/web/admin/lib/lang/ja_server_config.lng +++ b/interface/web/admin/lib/lang/ja_server_config.lng @@ -24,6 +24,7 @@ $wb['mailuser_uid_txt'] = 'メールユーザーのUID'; $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'] = 'リレーホストパスワード'; diff --git a/interface/web/admin/lib/lang/nl_server_config.lng b/interface/web/admin/lib/lang/nl_server_config.lng index 5d08e91f0bacab4214446c36c3440b7c52e6c3ae..6847356d4ec19c0be2b9be323b245fffe91edd91 100644 --- a/interface/web/admin/lib/lang/nl_server_config.lng +++ b/interface/web/admin/lib/lang/nl_server_config.lng @@ -24,6 +24,7 @@ $wb['mailuser_uid_txt'] = 'Mailuser UID'; $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'; diff --git a/interface/web/admin/lib/lang/pl_server_config.lng b/interface/web/admin/lib/lang/pl_server_config.lng index 32c4c00e5d973350023cf3f8766757e8bf5bbc73..ec51f689a7575f040c51e06a11a9351c869a26de 100644 --- a/interface/web/admin/lib/lang/pl_server_config.lng +++ b/interface/web/admin/lib/lang/pl_server_config.lng @@ -24,6 +24,7 @@ $wb['mailuser_uid_txt'] = 'UID użytkownika e-mail'; $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'; diff --git a/interface/web/admin/lib/lang/pt_server_config.lng b/interface/web/admin/lib/lang/pt_server_config.lng index e427ed91cbf135c45a35e3f72ff9a4c69c23723a..0fee45fb618ed33cc99469153bfebe18f0dd790b 100644 --- a/interface/web/admin/lib/lang/pt_server_config.lng +++ b/interface/web/admin/lib/lang/pt_server_config.lng @@ -23,6 +23,7 @@ $wb['mailuser_uid_txt'] = 'UID utilizador de email'; $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'; diff --git a/interface/web/admin/lib/lang/ro_server_config.lng b/interface/web/admin/lib/lang/ro_server_config.lng index 55b7355602bdb36d8b709a0eba07eff66656c9a5..e0a43db87b57af309096fbee505e59ea336841f4 100644 --- a/interface/web/admin/lib/lang/ro_server_config.lng +++ b/interface/web/admin/lib/lang/ro_server_config.lng @@ -23,6 +23,7 @@ $wb['mailuser_uid_txt'] = 'Mailuser UID'; $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'; diff --git a/interface/web/admin/lib/lang/ru_server_config.lng b/interface/web/admin/lib/lang/ru_server_config.lng index 5ae21a926237e324dffde8648c78834b1056a6ec..79cdfe0b3a1e80d7b39d2ce1806259a7107b4829 100644 --- a/interface/web/admin/lib/lang/ru_server_config.lng +++ b/interface/web/admin/lib/lang/ru_server_config.lng @@ -21,6 +21,7 @@ $wb['mailuser_uid_txt'] = 'Mailuser UID'; $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-хоста'; diff --git a/interface/web/admin/lib/lang/se_server_config.lng b/interface/web/admin/lib/lang/se_server_config.lng index 089e629be37fbd044f7ddd8d5fe7511e5f1c21e4..bf3fe039b6e9696d71e858c8dbdaac481e5c961d 100644 --- a/interface/web/admin/lib/lang/se_server_config.lng +++ b/interface/web/admin/lib/lang/se_server_config.lng @@ -22,6 +22,7 @@ $wb['mailuser_uid_txt'] = 'Mailuser UID'; $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'; diff --git a/interface/web/admin/lib/lang/sk_server_config.lng b/interface/web/admin/lib/lang/sk_server_config.lng index c01606bf04c98c6b2c01de87cc1c3b367a0d70ff..74ff9940386347d181d98bd1e0df9e7783c0f9ef 100644 --- a/interface/web/admin/lib/lang/sk_server_config.lng +++ b/interface/web/admin/lib/lang/sk_server_config.lng @@ -24,6 +24,7 @@ $wb['mailuser_uid_txt'] = 'Mailuser UID'; $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'; diff --git a/interface/web/admin/lib/lang/tr_server_config.lng b/interface/web/admin/lib/lang/tr_server_config.lng index 81595ff565ecc71284e56bef719c49a4432e201b..fe2b28697f0e2a74b0829c34f4f77f3b31a2799b 100644 --- a/interface/web/admin/lib/lang/tr_server_config.lng +++ b/interface/web/admin/lib/lang/tr_server_config.lng @@ -24,6 +24,7 @@ $wb['mailuser_uid_txt'] = 'Mail kullanıcısı UID'; $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'; diff --git a/interface/web/admin/templates/server_config_mail_edit.htm b/interface/web/admin/templates/server_config_mail_edit.htm index 6ab03eb9bd630caf06ab6a41a5c8d788cd314afa..991f1b0cea39df974c3b1edbdb2b45d79363eaaf 100644 --- a/interface/web/admin/templates/server_config_mail_edit.htm +++ b/interface/web/admin/templates/server_config_mail_edit.htm @@ -55,6 +55,12 @@ +
+

{tmpl_var name='mailbox_virtual_uidgid_maps_txt'}

+
+ {tmpl_var name='mailbox_virtual_uidgid_maps'} +
+
diff --git a/interface/web/mail/mail_user_edit.php b/interface/web/mail/mail_user_edit.php index 61f27cb2608565dff7aa49f5d8d2d04e00764e0e..435489f0909e1a65964eff4c0be8f93d45a43da1 100644 --- a/interface/web/mail/mail_user_edit.php +++ b/interface/web/mail/mail_user_edit.php @@ -203,9 +203,11 @@ class page_action extends tform_actions { $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")."
"; diff --git a/interface/web/themes/default-304/templates/admin/server_config_mail_edit.htm b/interface/web/themes/default-304/templates/admin/server_config_mail_edit.htm index 72292b32bf8c35987308ace171d16ab39c6b331e..7293b2ca8b91db7948ad6e17702e5ed2c7074b2a 100644 --- a/interface/web/themes/default-304/templates/admin/server_config_mail_edit.htm +++ b/interface/web/themes/default-304/templates/admin/server_config_mail_edit.htm @@ -51,6 +51,12 @@
+
+

{tmpl_var name='mailbox_virtual_uidgid_maps_txt'}

+
+ {tmpl_var name='mailbox_virtual_uidgid_maps'} +
+
diff --git a/interface/web/themes/default-304/templates/mail/spamfilter_config_mail_edit.htm b/interface/web/themes/default-304/templates/mail/spamfilter_config_mail_edit.htm index 524c9804b0a9dd45863d6c4eae2dd22b0aee66cc..e51a780a57d7ebc6d8560202e1e80a6193086c97 100644 --- a/interface/web/themes/default-304/templates/mail/spamfilter_config_mail_edit.htm +++ b/interface/web/themes/default-304/templates/mail/spamfilter_config_mail_edit.htm @@ -33,6 +33,12 @@ +
+

{tmpl_var name='mailbox_virtual_uidgid_maps_txt'}

+
+ {tmpl_var name='mailbox_virtual_uidgid_maps'} +
+
diff --git a/server/lib/classes/system.inc.php b/server/lib/classes/system.inc.php index a393384c96b7c77bca45360f7643fc85ea414c4e..9b7d9940a08e7837c48c60e323d12e4c7116da62 100644 --- a/server/lib/classes/system.inc.php +++ b/server/lib/classes/system.inc.php @@ -605,6 +605,30 @@ class system{ + /** + * 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 * @@ -632,6 +656,30 @@ class system{ + /** + * 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; + } + + + + + /** * Get the group id from an group * @@ -1476,7 +1524,7 @@ class system{ } } - function maildirmake($maildir_path, $user = '', $subfolder = '') { + function maildirmake($maildir_path, $user = '', $group = '', $subfolder = '') { global $app; @@ -1490,22 +1538,24 @@ class system{ 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); diff --git a/server/plugins-available/mail_plugin.inc.php b/server/plugins-available/mail_plugin.inc.php index 4a308da615a5f805d83e514819ca036eef960c0d..72b69a3c119332b7e851e67ba30a39cf4c572fe2 100644 --- a/server/plugins-available/mail_plugin.inc.php +++ b/server/plugins-available/mail_plugin.inc.php @@ -92,17 +92,48 @@ class mail_plugin { 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 @@ class mail_plugin { 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 @@ class mail_plugin { 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 @@ class mail_plugin { 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,24 +301,28 @@ class mail_plugin { 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'])) { if(is_dir($data['new']['maildir'])) { @@ -301,8 +339,8 @@ class mail_plugin { // 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);