0

I want to transfer Full amount of data(All subfolders) from one imap server to another , without any data loss.

2 Answers 2

1

I'm not sure what you mean by 'PHP Email Migration', as I don't see how PHP fits into the equation.

That said, there are a few MAP migration tools that can accomplish what you are describing. I'm the cofounder of a product called YippieMove that can do this, but there are also other open source alternatives, like imapsync. If you spend some time on Google, you'll find more options.

1
  • Thank you all for your valuable replay
    – meginjoy
    Jul 28, 2015 at 6:26
1

As vpetersson mentioned, it doesn't quite fit with the PHP part as migrating emails from one Imap to another Imap server can be done so easily with ANY imap client software as well, for examle, microsoft outlook, Mozilla Thunderbird, Apple Mail client and so on. How can you do it is simple. If the number of email accounts that you need to migrate are limited, here is the sample workflow for Mozilla Thunderbird and you can follow same process on any other client too.

  1. Make a new Imap account, and name it Source. [make sure you select IMAP as protocol and NOT POP]
  2. Configure it in a way that it can connect to the current source Imap server and depending on the volume of your emails in that account and speed of your net, it may take a while to synch all emails.
  3. Once synch is complete, create a new account for the target server, name it let say Target and configure it as IMAP too.
  4. Target account will be empty obviously, now simply copy all folders from Source account to Target account.
  5. Thunderbird will handle all the copy process and also it will upload all mails to new server automatically(as its the default behavior for IMAP account) Once done you will have a complete clone of your email account on both servers.

Alternately if you have to do it in PHP, maybe because you have hundreds of email accounts and going with the above mentioned method is not practical, then follow the below steps.

You can use PHP_Imap library too but if you have a control over your server, I will recommend using PEAR's Net_IMAP library, which has some features missing in php statdard IMAP library.

  1. Write a for loop for all your accounts and for each account
  2. connect to the server

    $imapServer = new Net_IMAP($emailHost, 143); $loggedIn = $imapServer->login($loginName , $password); if($loggedIn == true){ //code goes here }

  3. find all folders

    $mBoxes = $imapServer->getMailboxes('', 0, true);

  4. for each folder

    $mBox = $imapServer->selectMailbox($folderName);

  5. find all messages

    $msgsList = $imapServer->getMessagesList();

  6. get rawmessage.

    foreach($msgUid){ $fullRawMail = $imapServer->getMessages($msgUid,false); }

  7. connect to target server

  8. check if target server has the same folder as source, if it doesn't then create a folder

  9. upload raw message to target server [specific folder]. you can use php's imap_append function for that.

    imap_append($ImapStream, $folderName, $fullRawMail , "\Seen");

1
  • Thank you all for your valuable replay
    – meginjoy
    Jul 28, 2015 at 6:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.