| | |
| | | global $app, $conf; |
| | | |
| | | //* get the config |
| | | $app->uses("getconf"); |
| | | $app->uses("getconf,system"); |
| | | $mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail'); |
| | | |
| | | // convert to lower case - it could cause problems if some directory above has upper case name |
| | |
| | | // 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->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG); |
| | | $app->log('Created Directory: '.$maildomain_path,LOGLEVEL_DEBUG); |
| | | $maildomain_path .= '/Maildir'; |
| | | } |
| | | |
| | |
| | | //* Create the maildir, if it doesn not exist, set permissions, set quota. |
| | | if(!empty($maildomain_path) && !is_dir($maildomain_path)) { |
| | | |
| | | exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
| | | |
| | | 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); |
| | | } |
| | | 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); |
| | | } |
| | | 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); |
| | | } |
| | | 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); |
| | | } |
| | | //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); |
| | | |
| | | //* This is to fix the maildrop quota not being rebuilt after the quota is changed. |
| | | 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($mail_config['pop3_imap_daemon'] != 'dovecot') { |
| | | 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($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'); |
| | | } |
| | | 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'); |
| | | } |
| | | 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'); |
| | | } |
| | | 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'); |
| | | } |
| | | |
| | | //* Set the maildir quota |
| | | if(is_dir($data['new']['maildir'].'/new')) { |
| | | if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') { |
| | | 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); |
| | | } |
| | |
| | | global $app, $conf; |
| | | |
| | | // get the config |
| | | $app->uses("getconf"); |
| | | $app->uses("getconf,system"); |
| | | $mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail'); |
| | | |
| | | // convert to lower case - it could cause problems if some directory above has upper case name |
| | |
| | | |
| | | //* Create the maildir, if it doesn not exist, set permissions, set quota. |
| | | if(!empty($maildomain_path) && !is_dir($maildomain_path.'/new')) { |
| | | exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); |
| | | $app->log("Created Maildir "."su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
| | | |
| | | 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); |
| | | } |
| | | 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); |
| | | } |
| | | 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); |
| | | } |
| | | 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); |
| | | } |
| | | //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']); |
| | | |
| | | 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. |
| | | 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($mail_config['pop3_imap_daemon'] != 'dovecot') { |
| | | 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($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'); |
| | | } |
| | | 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'); |
| | | } |
| | | 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'); |
| | | } |
| | | 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'); |
| | | } |
| | | |
| | | // Move mailbox, if domain has changed and delete old mailbox |
| | |
| | | } |
| | | //This is to fix the maildrop quota not being rebuilt after the quota is changed. |
| | | // Courier Layout |
| | | if(is_dir($data['new']['maildir'].'/new')) { |
| | | if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') { |
| | | 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); |
| | | } |
| | | // Dovecot Layout |
| | | if(is_dir($data['new']['maildir'].'/Maildir/new')) { |
| | | exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."/Maildir' ".$mail_config['mailuser_name']); |
| | | $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."/Maildir' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); |
| | | } |
| | | } |
| | | |