View Single Post
  #15  
Old 13th June 2008, 11:30
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,413
Thanks: 834
Thanked 5,498 Times in 4,328 Posts
Default

I used the mb2md script to convert mailbox files:

http://batleth.sapienti-sat.org/projects/mb2md/

I used the following small php shell script to convert all mbox files at once with the mb2md script:

Code:
<?

// This script converts the content of mailboxes in /var/spool/mail
// to mail directories

$dir = "/var/spool/mail/";

if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
                if($file != '.' && $file != '..' && filesize("/var/spool/mail/".$file) > 0 && $file != 'Maildir') {
                        exec('mkdir /tmp/mb2md_temp');
                        $sourcefile = "/var/spool/mail/".$file;
                        $userid = fileowner($sourcefile);
                        $userinfo = posix_getpwuid($userid);
                        $username = $userinfo["name"];
                        $homedir = $userinfo["dir"];
                        $command = "/usr/bin/mb2md -s $sourcefile -d /tmp/mb2md_temp";
                        echo $command."\n";
                        exec($command);
                        $command = "chown $username /tmp/mb2md_temp/cur/*";
                        echo $command."\n";
                        exec($command);
                        $command = "mv /tmp/mb2md_temp/cur/* $homedir/Maildir/new/";
                        echo $command."\n";
                        exec($command);
                        exec("rm -rf /tmp/mb2md_temp");
                        exec("rm -f $sourcefile");
                }
        }
        closedir($dh);
        }
}



?>
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote