Connecting to a source IMAP server

Once the installation of CodeTwo Exchange Migration is finished, you have to choose a source environment from which the data will be pulled and migrated to selected mailboxes on target Exchange Server. This article describes how to connect to a source IMAP server.


You must be aware that to migrate via IMAP you need to have credentials in hand for all accounts you are about to migrate. In one of the further configuration steps you will be asked to provide them in a form of a CSV file. It is not possible to provide only a whole organization administrator's credentials to access other users' mailboxes via IMAP due to the IMAP protocol limitations.

Configure your IMAP source

All IMAP accounts are supported - especially those hosted by well-known free mail providers such as Google or Yahoo. However, some providers have IMAP protocol disabled by default and you have to enable it manually prior to migration. Other restrictions may also apply, please refer to your mail provider for details on how to allow IMAP access. Click a link below to learn more:

Migrate from Google

One of the most popular free as well as paid email accounts provider is Google with their Gmail service. Follow the steps below to be able to migrate from Google via IMAP:

  1. Sign in to your Google account (whether Gmail or Google Workspace [formerly G Suite]) and go to Security in the navigation menu on the left.
  2. In the How you sign in to Google section, click 2-Step Verification and use the wizard to enable the 2-step verification.
  3. Enter app passwords in the search box at the top of the page to find and open the App passwords settings (Fig. 1.).


    According to Google's documentation, you won't be able to create an app password for a Google account if:

    • 2-Step Verification is set up only for security keys,
    • it is a work, school or another organization account,
    • Advanced Protection is turned on for this account.

    If you can't access the App passwords settings, use a Google administrator account to temporarily disable the login challenge for the account you plan to migrate (see instructions). Once done, you now should be able to generate an app password for that account.

Accessing the App passwords settings in Google Account.
Fig. 1. Accessing the App passwords settings in your Google account.

  1. Type in your custom app name (e.g. CodeTwo Office 365 Migration) and click Create. Your password (16-character code) appears in a new pane. Copy the password (you won't be able to view it again) so that it can be used when configuring an IMAP migration job, then click Done.

Creating an app password.
Fig. 2. Creating an app password.

  1. Repeat steps 1-4 for each migrated mailbox separately.
  2. Now, go to your mail account Settings > Forwarding and POP/IMAP. Again, you can use the direct link:
  3. In the IMAP Access section, select the Enable IMAP option and click Save Changes.
  4. Go to the Labels tab and select the Show in IMAP checkboxes next to the names of labels you want to migrate (Fig. 3.).


    Remember to select the checkboxes not only for your custom labels, but also the default (system) Gmail labels like Important or Starred. These might not be selected by default, and, as a result, emails marked with them (and corresponding folders) won’t be migrated to the target.

    Also, if you do not enable the Show in IMAP option, items with such labels will not be migrated, unless they happen to be labeled twice or more and those other labels are made visible via IMAP by enabling the Show in IMAP option.

    Learn more about migrating labelled items from Gmail

    Selecting which folders with labelled items should be migrated.
    Fig. 3. Selecting which folders with labelled items should be migrated.

  1. Google Workspace only: using the admin account, sign in to Google Admin console, and go to Apps > Google Workspace > Gmail > End User Access. In the Organizational Units section, select your organizational unit. Hover your mouse cursor over the POP and IMAP access section and click the pencil (edit) icon on the right. In the pop-up that opens, select the checkbox next to Enable IMAP access for all users. Make sure that Allow any mail client is selected as well. Finally, click Save to apply your change(s).

More information on migrating labelled items’ folders from Gmail

Google's labels are visible as folders when accessing via IMAP. Therefore, after migrating via IMAP, you can have as many folders in the target mailbox as many labels you have in your Google account. For example, if you select the Show in IMAP option for 3 labels, as described in point 6 above, you will have 3 additional folders in the target mailbox, named as these labels.

Items that are labeled with multiple labels will be migrated to each of the corresponding target folders. For example, if one of your emails is labeled as Important and Starred, and for both these labels the Show in IMAP option is enabled, after the migration you will find two copies of this email in your target mailbox: in the Important folder as well as in the Starred folder.

Migrate from other IMAP sources

Pretty much any mail server is supported as a source of migration, providing that IMAP access is enabled and you are able to provide a list of credentials to access users' mailboxes. However, see the below notes for a few most popular mail services:

  • Zimbra - IMAP/POP Proxy must be configured first.
  • IBM Notes - Domino IMAP Service must be configured first.

Migrate from Exchange


  • If you are going to migrate from on-premises Microsoft Exchange Server, configure an EWS connection (Exchange 2010 SP1 or newer) or a MAPI connection (Exchange 2010 without SP1).
  • If you are going to migrate from hosted Microsoft Exchange Server 2010 or newer, configure an EWS connection, as described here.

That way, you will be able to migrate entire mailboxes, and not emails only (one of the IMAP’s limitations).

If you don’t have the necessary permissions to migrate from an Exchange server by using EWS or MAPI. configure your source environment as described below.

Migration from Microsoft Exchange Server via IMAP might be a useful option for clients using hosted (e.g. Rackspace) or otherwise limited access Exchange Server. Before starting CodeTwo software configuration, make sure you have enabled IMAP4 in your Exchange:

Configure the software

You can create a new source connection when you configure a migration job: click Create a new migration job on the How to start card (see Fig. 4.and select IMAP server. Then type the name of your job, and proceed to the Source mailboxes step. Select Add new source connection from the Source server list to open the source server connection wizardYou can also start the wizard by clicking the Settings (Exchange Migration settings button temp) button on the Defined source server connections card (Fig. 2.and choosing New > IMAP server connection.

How to open the source connection wizard.
Fig. 4. How to open the source connection wizard.

Either way, the IMAP source server connection wizard will open (Fig. 5.).

Configuring IMAP connection.
Fig. 5. Configuring IMAP connection.

In the first step (Server connection) you need to provide the following information to configure IMAP connection:

  • IMAP server - you can use either IP address or its network name (e.g. For your convenience, we have added the most popular IMAP servers' addresses, including Gmail, Yahoo, and more.
  • TCP port - under which the IMAP server is running on the server. Usually, it is 993 for encrypted connections (SSL) and 143 for non-encrypted ones.
  • Secure connection - this option lets you decide if the connection should be encrypted.


    Be advised, for mailboxes hosted in Google Workspace with your custom domain you need to choose the same settings as for free Gmail accounts.


    We strongly recommend using only encrypted (SSL) connections for your data safety. If you are not able to establish SSL connection to public IMAP servers (like Google or Yahoo), please check date and time in your system, as most probably there is an issue with SSL certificate. If still no joy, please contact your mail hosting provider.

Click Next to continue to the Throttling step (Fig. 6.). Here you can define how the program should limit connections to your IMAP server. Thanks to this feature, the program can suspend migration of mailboxes that exceeded server-side defined limits (if there are any) and continue the process for rest of them.

Configuring IMAP throttling.
Fig. 6. Configuring IMAP throttling.

Proceed by clicking Next, and finally click Configure, so the application will attempt to connect to the desired server. If the setup is successful (Fig. 7.), you are good to go and create a new IMAP job. 

Exchange Migration IMAP source wizard 3
Fig. 7. Verification of IMAP connection.

When you complete the wizard, the new connection should be displayed on the Defined server connections card (Fig. 8.).

Defined source server connections.
Fig. 8. Defined source server connections.

See next

Configuring a migration job

Configuring source mailboxes for IMAP connection

Managing server connections

See also

Troubleshooting IMAP connectivity

In this article

Was this information useful?