IMAP Migration to Microsoft Office 365
Below are the steps of email migration that will help you to Migrate your email from an IMAP (Internet Message Access Protocol) server to your Office 365 accounts.

Below are the steps of email migration that will help you to Migrate your email from an IMAP (Internet Message Access Protocol) server to your Office 365 accounts. The discussion will focus on the following points:
How the IMAP migration process works.
Prepare for an IMAP migration.
How to Create a CSV file for the IMAP migration batches.
For Configure MX record to point to Office 365
Best practices
Troubleshooting
How the IMAP migration process works
1. Administrator provisions new Exchange Online mailboxes by creating O365 user account and assigning Exchange Online user licenses.
2. An administrator creates a CSV file that contains a row for each user whose IMAP mailbox will be migrated.
3. Administrator creates and starts an IMAP migration batch using the Migration dashboard in the EAC or using the Shell.
4. After the administrator starts the Batch email migration, Exchange Online does the following:
◦ Creates a migration request for each user listed in the CSV file. Each of the email migration requests contains the username and encrypted password for the account in the IMAP messaging system.
◦ Starts processing migration requests. This part of the process is called initial synchronization. Exchange Online processes up to N migration requests at one time, where N is the maximum number of concurrent migrations that the administrator specified when creating the migration endpoint used for the migration batch. By default, the initial synchronization is performed on 10mailboxes at a time until all mailboxes in the migration batch have been migrated to the new mailbox.
◦ Processes the migration requests for all the users listed in the CSV file.
5. When the initial synchronization is completed for a migration batch of emails, Exchange Online sends a status email message to the administrator. This notification message lists the number of mailboxes that were successfully migrated and how many users could not be migrated.
6. This is called incremental synchronization this will take an interval of every 24 hours. This means that any new email messages sent to the mailboxes on the IMAP server are copied to the corresponding Exchange Online mailbox. After the default, incremental synchronization is performed at the 10 mailboxes at a time until all email boxes Synchronized. Incremental synchronization continues until the admin stops or deletes the email migration batch.
Prepare for an IMAP migration
For before you migrate mail from an IMAP server, be sure to plan your email migration carefully, especially if you're migrating lots of users. When you plan, make sure to check out Best practices, it's important.
>To Create an Exchange Online mailbox for each user that you will migrate. Before you can migrate mailbox data from a user's mailbox on the IMAP server, the user has to have an Exchange Online mailbox.
>Obtain the FQDN of the IMAP server. You need to provide the FQDN (fully qualified domain name), also called the full computer name of the IMAP server that you will migrate mailbox data from, when you create an IMAP migration endpoint. Use an IMAP client or the PING command to verify that you can use the FQDN to communicate with the IMAP server over the Internet.
>To Verify that user can connect to your IMAP server. Run the following command in the Shell to test the connection settings to your IMAP server.
Test-MigrationServerAvailability -IMAP -RemoteServer <FQDN of IMAP server> -Port <143 or 993> -Security <None, Ssl, or Tls>
For the value of the Port parameter, it’s typical to use 143 for unencrypted or TLS connections and to use 993 for SSL connections.
>To Configure the firewall to allow IMAP connections. You may have to open ports in the firewall of the organization that hosts the IMAP server, so network traffic originating from the Microsoft datacenter during the migration is allowed to enter the organization that hosts that IMAP server.
>Determine if you don't want to migrate selected folders from the IMAP messaging system. You may not want to migrate the contents of specific folders, such as Deleted Items and Junk Mail, and shared or public folders.
If you are migrating emails from an on-premises Microsoft Exchange server, we recommend that you exclude public folders from the migration. If you don't exclude the public folders, then the contents of the public folders are copied to the Exchange Online mailbox of every user in the CSV file.
Assign the administrator account permissions to access mailboxes in your Exchange organization. If you use administrator credentials in the CSV file, the account that you use must have the necessary permissions to access the on-premises mailboxes. The permissions required to access the user's mailbox will be determined by the particular IMAP server. The following list shows the administrative privileges required for email migration to the Exchange mailbox data using an IMAP migration. There are three options.
The administrator account must be assigned the Full Access permission for each user mailbox on the Exchange server.
Or
The admin account must be assigned the Receive as a permission on the Exchange mailbox database that stores the user mailbox.
Or
The administrator account must be a member of that Domain or in Active Directory of the on-premises Exchange organization.
How to Create a CSV file for an IMAP email migration batch
>To Identify the group of users whose mailboxes you want to migrate in an IMAP migration batch. Each row in the CSV file contains the information necessary to connect to a mailbox in the IMAP messaging system.
>Here are the required attributes for each user:
• Email Address specifies the user ID for the user's Exchange Online mailbox.
• The UserName specifies the login name for that email account to use to access the mailbox on the IMAP server.
• Password specifies the password for the account in the User Name column.
Note:
A CSV file for an IMAP migration can have a maximum of 50,000 rows. If you have to migrate email data for thousands of mailboxes, it's a good idea to migrate users in several smaller batches. For example, if you have 5,000 accounts to migrate, you could run five batches with 1,000 users each, or you could divide the batches alphabetically, by user type, by department, or in other ways that meet your organization's needs. If the same user appears in two different CSV files, Exchange Online will generate a validation error for the migration batch that contains the user that was already migrated.
Configure MX record to point to Office 365
Until you change your MX record, email sent to users is still routed to their mailboxes in the IMAP messaging system. After a mailbox is successfully migrated, the mailbox on the IMAP server and the Exchange Online mailbox are synchronized once every 24 hours, in a process called incremental synchronization, until you stop or delete a migration batch. This lets users use their Exchange Online mailbox to access email sent to their IMAP mailbox. When you configure your organization's MX record to point to your Office 365 email organization, all emails are sent directly to the Exchange Online mailboxes.
After you change the MX record and verify that all emails are being routed to Exchange Online mailboxes, you can delete the IMAP migration batches
It will take from 24 to 72 hours for the updated MX record to be propagated. After waiting at least 24 hours you can change the MX record and then verify that mail is being routed directly to Exchange Online mailbox.
Best practices
Find here are some tips for optimizing your IMAP migration:
> Increase the connections limit to your IMAP server. In that many of firewalls and email servers have per-user limits, per-IP address limits, and overall connection limits. Before your start the email migrate to mailboxes, ensure that your firewall and IMAP server are configured to allow a large, or maximum, number of connections for the following settings:
◦ Total number of connections to IMAP.
◦ The number of connections by a particular user. This is important if you use an administrator account in the CSV migration file because all connections to the IMAP server are made by this user account.
◦ The number of connections from a single IP address. This limit is typically enforced by the firewall of the email server.
> If your IMAP server is running in Microsoft Exchange Server 2010 or Exchange 2007, the default settings for connection limits are low. Be sure to increase that limit before you email migrate. By default, Exchange 2003 does not limit the number of connections.
>Change the DNS TTL(Time-to-Live) setting on your MX record. Before you start the migration of user mailboxes, change the DNS TTL setting on your current MX record to a shorter interval, such as 3,600 seconds (one hour).So that, when you change the MX record to point to your Office 365 email organization all email quickly because of the shortened.
>Run one or more test migration batches. Run a few small IMAP migration batches before you migrate huge numbers of users. In a test migration, you can do the following:
◦ Verify the format of the CSV file.
◦ Test the email migration endpoint used to connect to the IMAP.
◦ Verify that you can successfully migrate email using administrator credentials, if applicable.
◦ Determine the optimal number of simultaneous connections to the IMAP server that minimize the impact on your Internet bandwidth.
◦ Verify that folders you exclude aren't migrated to Exchange Online mailboxes.
◦ How to Determine the duration it takes to migrate a batch of users.
>IMAP: If you decide to use user credentials in the CSV file, consider changing users' passwords globally and then preventing users from changing their password on their on-premises account before you migrate their mailboxes. If users change the password before their mailbox is migrated to the cloud-based mailbox, the migration will fail. If they change their password after the mailbox is migrated, new email sent to their mailbox on the IMAP server won’t be migrated to their Exchange Online mailbox.
>Do not delete the email mailbox or change their SMTP addresses during the email migration. The migration system will report an error when it cannot find a mailbox that's been migrated. Be sure to complete the migration and delete the migration batch before you delete or change the SMTP address of an Exchange Online or on-premises mailbox that's been migrated.
◦ Inform the users that email messages larger than 35 MB will not be migrated. Ask users to save very large messages and attachments to their local computer or removable devices.
◦ Suggest that users backup their Inboxes.
◦ Folders with a forward slash ( / ) in the folder name aren't migrated. If the users want to migrate their folders that contain forward slashes in their names, they have to rename the folders or replace the forward slashes with a different character, such as an underscore character ( _ ) or a dash ( - ).
Troubleshooting
Common IMAP migration errors:
Error: A cloud-based mailbox wasn't found for the user.
Confirm that the cloud-based mailbox exists. If it doesn't, create a cloud-based mailbox for the user.
Verify that you're using the correct email address for the user's cloud-based mailbox.
Error: The user's mailbox has already been migrated.
If you are running a new email migration batch, in the CSV file, remove the rows for mailboxes that have already been migrated.
Error: Microsoft Exchange couldn't connect to the IMAP server.
Verify that the IMAP service is running properly or not.
Error: The user's cloud-based mailbox is full.
Free up space in the user's cloud-based mailbox.
Reference: http://help.outlook.com/en-us/140/Ee695827.aspx