View Single Post
Old 24th April 2009, 11:22
andypl andypl is offline
Senior Member
Join Date: Mar 2006
Location: Warsaw, Poland
Posts: 100
Thanks: 1
Thanked 5 Times in 4 Posts

Originally Posted by ihamouda View Post
you need to add the maildirmake command not the mkdir command like the follwoing:

to add a .Spam folder use the -f option and don't forget the su -c surrounding the whole command

exec("su -c 'maildirmake -f Spam ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']);
Still not working.

        function user_insert($event_name,$data) {
                global $app, $conf;

                //* get the config
                $mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');

                $maildomain_path = $data['new']['maildir'];
                $tmp_basepath = $data['new']['maildir'];
                $tmp_basepath_parts = explode('/',$tmp_basepath);
                $base_path = implode('/',$tmp_basepath_parts);

                //* 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->log('Created Directory: '.$base_path,LOGLEVEL_DEBUG);

                //* 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']);
                //* Create .Spam and .NoSpam folder
                        exec("su -c 'maildirmake -f Spam ".escapeshellcmd($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 b$
                        $app->log('Created Maildir: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLE$

                //* Set the maildir quota
                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'],LOGL$
Reply With Quote