A few things have changed since the last time I posted the IMAP migration script, and my wishlist of features is almost complete. Instead of a single file that you have to manually specify variables in, you now have fillable form that uses jQuery.post to send variables to another file (called process.php), which handles the actual migration. What this does is solve the memory issue, as you can specify the incremental value (number of emails it will transfer at a time) and it also makes it a little more user-friendly. I added support for unread emails (instead of just marking everything as read), and changed the imap_body command to “peek” instead of doing a full open, which marks the email as read as it’s transferring. This time around I am not going to post the code, but it will be included in the zip file.
On the todo list is directory traversing for people who organize their emails into folders, and some bug fixes.
Unzip this into a folder on your server, then run “email.php” from your browser.
I have been looking for mail migration tool that can retain the datetime of the original messages and the process was long and painstakingly. I’m grateful I’ve found your code here. Now I can move mailboxes to another mail server easily along with the original datetime of each message which is really important for me. Thank you, Brendan, for sharing the code, it works great.
Glad to help. The final code ended up in transfermyemail.ca – so if you need to be able to move specific folders it can now do that too.