Zang my English is very bad, but with the help of google translator will try to describe what we did.
in our old server we had a test database containing all users of the mail server. this database the information is on the table TNAccount. use the concat command to generate the migration scripts that generate the lines for migration in bulk using your script in py (create_mail_user_OpenLDAP.py), see if you can understand:
in mysql prompt:
select concat('fama.br, ',username,', ',password,', ',fullname,', 262144000, ') from TNAccount
the output is:
fama.br, postmaster, password, Postfix, 262144000,
fama.br, abuse, password, Conta do postfix, 262144000,
fama.br, user, password, Test User, 262144000,
fama.br, webmaster, password, Webmaster - ASCOM Administracao Pagina, 262144000,
etc (all user of the email server)
save it as user.csv and use create_mail_user_OpenLDAP.py to gerate .ldif wich all users. (import it using phpldapadmin)
using concat again we will create the command to in conjunction with the imap sync synchronize the accounts of all users
in mysql prompt:
*192.168.0.200 = old server (tnmail)
*192.168.0.100= new server (iredmail)
SELECT concat('imapsync --host1 192.168.0.200 --user1 ', `Username` , '@fama.br --password1=' , `Password` , ' --host2 192.168.0.100 --user2 ', `Username` , '@fama.br --password2=' , `Password` , ' --noauthmd5 --subscribe ') as comando FROM `TNAccount`
the output is:
imapsync --host1 192.168.0.200 --user1 webmaster@fama.br --password1=password --host2 192.168.0.100 --user2 webmaster@fama.br --password2=password --noauthmd5 --subscribe
imapsync --host1 192.168.0.200 --user1 postmaster@fama.br --password1=password --host2 192.168.0.100 --user2 postmaster@fama.br --password2=password --noauthmd5 --subscribe
imapsync --host1 192.168.0.200 --user1 user@fama.br --password1=password --host2 192.168.0.100 --user2 user@fama.br --password2=password --noauthmd5 --subscribe
imapsync --host1 192.168.0.200 --user1 webmaster@fama.br --password1=password --host2 192.168.0.100 --user2 webmaster@fama.br --password2=password --noauthmd5 --subscribe
(etc... all user )
save the output wich the name migration.sh (chmod +x) in new server and use ./migration.sh in newserver