Thanks everyone. I finished this account migration. This is the script:
PHP Code:
#!/usr/bin/php
// http://wiki.zimbra.com/index.php?title=Password_Migration
// Modified migration script for gentoo+qmail+vpopmail
//
<?php
/////////////////////////////////////////////////////////
$user="user";
$pass="password";
$db="vpopmail";
$table_mbox="vpopmail";
$file="exported.sh";
/////////////////////////////////////////////////////////
echo "This script generates a bash script called: $file
The script contains the commands to re-create the mail accounts on zimbra server.\n\n
";
$mydb = mysql_connect('localhost',$user, $pass) or die ('Error connecting to server');
mysql_select_db($db);
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES utf8");
$query = "SELECT pw_name,pw_domain,pw_passwd
FROM $table_mbox";
$dane = mysql_query($query) or die ('Error during query for '.mysql_error());
echo "Writing to $file ...\n";
$fh = fopen($file, "w");
$sp = '@';
fwrite($fh, "#!/bin/sh -x\n\n");
while ($row = mysql_fetch_array($dane, MYSQL_NUM))
{
$data_mbox = "zmprov ca ".$row[0]."".$sp."".$row[1]." dsfs123hsdyfgbsdgfbsd displayName '".$row[0]."'\n";
$data_mbox .= "zmprov ma ".$row[0]."".$sp."".$row[1]." userPassword '{crypt}".$row[2]."'"."\n";
fwrite($fh, $data_mbox);
}
echo "Done.";
Once again thanks evryone ....