The Wild

Dovecot to Office 365 Migration: Step-by-Step

· 6 min read · Mammals

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Migrating from Dovecot (an open-source IMAP/POP3 server) to Microsoft 365 (Exchange Online) moves your email hosting to the cloud, giving you Outlook, webmail, and integrated collaboration tools. This guide walks you through a cutover migration—the most common method for small to medium mailboxes—using Microsoft’s built-in migration tools. You’ll need admin access to both your Dovecot server and your Microsoft 365 tenant, plus a list of all user mailboxes with their credentials (or a way to generate app passwords).

What You'll Need

  • Microsoft 365 tenant with Exchange Online licenses assigned to all users.
  • Global admin or Exchange admin access to the Microsoft 365 admin center.
  • Admin access to the Dovecot server (SSH or console) to create migration accounts.
  • A CSV file listing each mailbox: email address, username, and password (or an app-specific password).
  • IMAP enabled on Dovecot (usually on port 143 or 993 with SSL).
  • Stable internet connection—migration speed depends on your bandwidth and mailbox sizes.

Step-by-Step

  1. Prepare your Dovecot server. Ensure IMAP is running and accessible from the internet or from Microsoft’s data centers. If your server is behind a firewall, allow connections from Microsoft’s IP ranges (see Microsoft documentation for current ranges). Also, create a dedicated migration user (e.g., migration@yourdomain.com) with read access to all mailboxes, or prepare individual credentials for each mailbox.
  2. Verify your domain in Microsoft 365. In the Microsoft 365 admin center, go to Setup > Domains, add your email domain (e.g., yourdomain.com), and follow the verification steps (usually adding a TXT record to your DNS).
  3. Create user mailboxes in Microsoft 365. For each Dovecot user, create a corresponding user in Microsoft 365 with an Exchange Online license. You can do this manually or via PowerShell. Use the same email address as the Dovecot mailbox.
  4. Set up a cutover migration endpoint. In the Exchange admin center (EAC), go to Recipients > Migration, click + New, and select Migrate to Exchange Online. Choose Cutover migration (for up to 2,000 mailboxes).
  5. Configure the IMAP endpoint. When prompted, enter the Dovecot server’s IMAP server name (e.g., mail.yourdomain.com), port (993 for SSL, 143 for TLS), and encryption method. Use the migration admin account credentials or leave blank if you’ll provide per-user credentials later.
  6. Upload the CSV file. Create a CSV with columns: EmailAddress,UserName,Password. For each user, put the Microsoft 365 email address in the first column, the Dovecot login username in the second, and the Dovecot password in the third. Save as migration.csv and upload it when the wizard asks.
  7. Run the migration. Review the mailbox list, then click Start migration. The initial sync will copy all folders, subfolders, and messages from Dovecot to Exchange Online. This may take hours or days depending on data volume.
  8. Monitor progress. In the migration dashboard, check the status of each mailbox. You can pause or restart individual migrations if needed. After the initial sync, you’ll get a “Synced” status, but changes made on Dovecot after that point will be incremental.
  9. Switch DNS records. Once the initial sync is complete and you’ve tested a few mailboxes, update your DNS MX record to point to Microsoft 365 (e.g., yourdomain.mail.protection.outlook.com). Also update Autodiscover (CNAME) to autodiscover.outlook.com and SPF record to include include:spf.protection.outlook.com.
  10. Final incremental sync and cutover. After DNS propagates (may take up to 48 hours), run a final incremental sync to capture any remaining emails. Then, in the migration dashboard, click Complete for each mailbox. This stops the migration and makes Exchange Online the primary mailbox.
  11. Verify and decommission. Have users test sending/receiving in Outlook or Outlook on the web. Once you’re confident, you can remove the migration endpoint and eventually shut down the Dovecot server.

Common Mistakes

  • Not enabling IMAP on Dovecot. Some Dovecot installations only have POP3 enabled. Check protocols = imap pop3 in dovecot.conf and restart the service.
  • Using wrong credentials in CSV. The CSV requires the Dovecot login username (which might be the full email or just the local part) and the correct password. A single typo fails the entire migration.
  • Forgetting to assign licenses. If a user doesn’t have an Exchange Online license, the migration will fail with an error.
  • Migrating before DNS verification. You must verify domain ownership before creating migration endpoints.
  • Not accounting for large mailboxes. If a mailbox is over 50 GB, cutover migration may time out. Consider using a staged migration or third-party tools for very large mailboxes.

Tips

  • Run a test migration with one or two non-critical mailboxes first to validate the process.
  • Use an app password for Dovecot accounts that have two-factor authentication enabled, or temporarily disable 2FA during migration.
  • Communicate with users about expected downtime—they may see old emails disappear if they access their mailbox during the cutover.
  • Keep the Dovecot server running for at least a week after cutover to allow for any missed emails.
  • Use PowerShell for bulk operations if you have many users—creating mailboxes and assigning licenses is faster via the Exchange Online module.

Troubleshooting

  • Migration fails with “Connection to source server failed.” Check that your Dovecot server is reachable from the internet, IMAP is listening, and SSL certificates are valid. Test with a telnet or IMAP client from an external network.
  • Mailboxes show “Failed” status. Look at the error details in the migration dashboard. Common issues: incorrect CSV passwords, mailbox not existing, or the migration admin account lacks permissions.
  • Emails missing after cutover. Run a final incremental sync before completing. If still missing, check if the Dovecot folder structure uses special characters that Exchange doesn’t support (e.g., some Unicode).
  • Users can’t log in to Outlook. Ensure their Microsoft 365 password is set and they are using the correct UPN (usually the email address). Also, verify Autodiscover DNS is correct.
  • Migration is extremely slow. IMAP migrations are rate-limited by Microsoft. For large data, consider using a third-party migration tool that supports parallel connections.

Frequently Asked Questions

Can I migrate without providing user passwords?

Yes, you can set up a single migration admin account on Dovecot that has read access to all mailboxes. However, this requires configuring Dovecot’s master user feature (e.g., using master_user or auth_master_user_separator). If that’s not possible, you’ll need per-user credentials in the CSV.

How long does the migration take?

It depends on the number of mailboxes, total data size, and your internet bandwidth. As a rough guide, 10 GB per hour is typical, but it can vary widely. Plan for a few days for larger environments.

Will my folder structure and subfolders be preserved?

Yes, IMAP migration preserves the folder hierarchy, including subfolders and their messages. Special characters like “.” or “/” might be converted to match Exchange’s naming conventions.

What happens to emails sent during the migration?

Emails sent to your domain during the migration will be delivered to Dovecot if DNS still points there. The incremental sync will pick them up. If you’ve already switched DNS, they’ll go to Exchange Online, and you’ll need to forward or manually copy any missed messages.

Can I migrate just a few mailboxes instead of all?

Cutover migration migrates all mailboxes on the server. If you need to migrate a subset, use a staged migration (requires IMAP and per-user credentials) or a third-party tool that allows selective migration.

Do I need to keep the Dovecot server after migration?

It’s recommended to keep it for at least 30 days as a backup. Once you’re certain all data is in Exchange Online, you can decommission it.