Microsoft 365

cPanel to Microsoft 365 Migration: Step-by-Step, MX Cutover Included

Move cPanel mailboxes to Microsoft 365 in phases or all at once: IMAP batches, split delivery with a connector and rule, MX cutover, SPF, DKIM and cleanup.

By EpiFive Editorial TeamReviewed/updated 19 min readHow we check our guides
On this page

To migrate a cPanel domain to Microsoft 365, you create licensed mailboxes, copy each cPanel mailbox with an IMAP migration batch, and then point the domain's MX record at Microsoft 365. If everyone cannot move on the same day, you set up split delivery first so that mail for the domain reaches whichever system holds the mailbox. Only mail moves; contacts, calendars and tasks do not, and the MX record stays untouched until the last step is tested.

Who this is for and what you will have

This guide is for administrators of a small or mid-sized organization whose email lives on cPanel hosting and who are moving to Exchange Online. It covers one domain, either moved in a single weekend or in phases. By the end you will have:

  • Every chosen mailbox copied into Microsoft 365, with a way to watch the batch and read its log.
  • A tested split delivery setup if some users stay on cPanel for a while.
  • The MX record switched, SPF and DKIM updated, and Outlook configured automatically through autodiscover.
  • A clean decommission of cPanel mail, with the Microsoft 365 domain set back to Authoritative.

The generic mechanics of an IMAP batch (CSV columns, endpoint options, throttling) are in the IMAP to Exchange Online migration guide; this article does not repeat them line by line. It adds the cPanel-specific plan, the phased route, the cutover order and the cleanup. The email migration cutover checklist is a good companion for the DNS day.

Placeholders used throughout: example.com is your domain, [email protected] is the Microsoft 365 admin, yourtenant.onmicrosoft.com is the tenant's default domain, mail.example.com is the cPanel mail host, and 203.0.113.10 is the cPanel server's public IP.

Choose your route: one cutover or phased

One cutoverPhased (split delivery)
Who movesAll mailboxes in one windowSome now, the rest later
Mail routing in betweenNot neededConnector plus mail flow rule, domain set to Internal relay
cPanel Email RoutingSwitched to Remote Mail Exchanger after MX changeLocal Mail Exchanger until the last user moves
Extra riskShort outage window if DNS lagsMail loops and misrouted mail if one setting is wrong
Use whenFewer than a few dozen mailboxes and a quiet weekendLarge mailboxes, staggered training, or users who must stay on cPanel for now

If you can do one cutover, do it: it has fewer moving parts. The phased route in the section "Phased moves with split delivery" is the same migration plus a routing layer.

Step 1: Plan and take inventory

Before touching Microsoft 365, write down what exists on the cPanel side.

  1. Mailboxes. In cPanel, open Email > Email Accounts and list every account and its disk usage.
  2. Forwarders and aliases. Open the Forwarders page. cPanel documents that if a forwarder shares an address with an email account, both receive mail. Note every forwarder, because each one needs an equivalent in Microsoft 365 (an alias, a shared mailbox or a contact).
  3. Catch-all and autoresponders. Note them, and decide how each will be handled in Microsoft 365 before cutover, because the IMAP migration does not carry them.
  4. Limits to plan around. Microsoft documents a maximum of 500,000 items per mailbox (newest first), a 35 MB maximum message size, and that only mail folders migrate. Ask users to tidy up and save large attachments first.
  5. Lower the MX TTL. Microsoft recommends a TTL of 3,600 seconds (one hour) or less on every MX record before you start. 3,600 seconds is 60 minutes, so after the change most senders re-check within the hour.
  6. Disable retention and archive policies on target mailboxes until the migration finishes. Microsoft warns the migration reports items moved by those policies as missing.

Step 2: Add the domain and create users (do not change MX)

  1. In the Microsoft 365 admin center, add and verify example.com under Settings > Domains. Follow the prompts, but do not accept any step that changes the MX record.
  2. Create users and assign a licence that includes Exchange Online. Microsoft requires that target mailboxes exist before an IMAP migration; the migration does not create them.
  3. Create users only for the mailboxes moving now. In a phased move, a user created in Microsoft 365 starts receiving that address's mail, so never create an account for someone who is staying on cPanel.

Leave the MX record pointing at cPanel. Do not add the Microsoft 365 MX, SPF or autodiscover records yet.

Step 3: Prepare the cPanel side and the CSV

Find the IMAP server and test it

In cPanel, open the mail client settings for any mailbox (under Email > Email Accounts). Use the incoming server name shown for the secure SSL/TLS settings and IMAP port 993. The migration endpoint in the next step needs exactly that name, for example mail.example.com.

Get credentials safely

The CSV needs EmailAddress, UserName and Password. Attributes cannot contain spaces. You have three ways to get working credentials:

  • Known passwords. Fine if users share them, but tell users not to change passwords during the migration. Microsoft says a password change after the initial migration makes later synchronizations fail.
  • Reset to temporary passwords. In cPanel, change each mailbox password and record it in the CSV. Users lose access to the old mailbox with their own password until you give them the new one.
  • Admin (super-user) credentials. For Dovecot, Microsoft documents the User_UserName*Admin_UserName format. This works only if the host has that configured; shared hosting often does not.
EmailAddress,UserName,Password
[email protected],[email protected],Temp-Passw0rd-1
[email protected],[email protected],Temp-Passw0rd-2

The CSV is a list of working passwords. Store it somewhere restricted and delete it, and the temporary cPanel passwords, when the migration is done. If the file has non-ASCII characters, save it as UTF-8.

Step 4: Create the endpoint and the batch

Connect to Exchange Online PowerShell, test the source, then create the endpoint and batch. Use a small test batch of two or three mailboxes first.

Connect-ExchangeOnline -UserPrincipalName [email protected]
 
Test-MigrationServerAvailability -IMAP -RemoteServer mail.example.com -Port 993 -Security Ssl
 
New-MigrationEndpoint -IMAP -Name cPanelEndpoint -RemoteServer mail.example.com -Port 993 -Security Ssl
 
$csv = [System.IO.File]::ReadAllBytes("C:\Migration\batch1.csv")
New-MigrationBatch -Name cPanelBatch1 -SourceEndpoint cPanelEndpoint -CSVData $csv -ExcludeFolders "Trash","Junk" -NotificationEmails [email protected] -AutoStart

The same steps exist in the Exchange admin center under Migration: Endpoints > Add > IMAP, then Add migration batch > Migrate to Exchange Online > IMAP migration, selecting your endpoint and importing the CSV on Add user mailboxes. Check the real folder names in a mail client before you exclude any, because they differ between hosts.

Step 5: Read the migration status and log

Check status with PowerShell

Get-MigrationBatch | Format-Table Identity,Status,TotalCount,SyncedCount,FailedCount
 
Get-MigrationUser | Format-Table Identity,Status,ErrorSummary
 
Get-MigrationUserStatistics -Identity [email protected] -IncludeReport | Format-List Status,SyncedItemCount,SkippedItemCount,Error,Report

Microsoft's migration user status documentation describes these states: Queued (batch running, user not started, typically because all endpoint connections are busy), Synced (initial sync done; for IMAP it can also mean an incremental sync succeeded), Failed (provisioning or the initial sync failed), and Completed. In the Exchange admin center, select the batch under Migration and use View details in the details pane for the per-user report, where Stop migration and Resume migration appear depending on the user's status.

What the report lines usually mean

The per-user report is a plain list of events. Microsoft does not document each line, so treat this as practical interpretation, not a specification:

Report line (typical)Usually means
Created request on behalf of the adminThe batch was submitted
Examining the requestThe Mailbox Replication service picked the job up
Connected to target mailbox (Primary)The Microsoft 365 mailbox is reachable
Sync state is nullFirst sync, not an error
Connected to source mailbox (IMAP) on port 993The SSL IMAP login worked
Version 0.0, empty database name, (None)Normal for an IMAP source

Worry about a Failed status with an Error text (usually a wrong or changed password, or a blocked connection), repeated connection errors in the report (network or the host's connection limits), and a non-zero SkippedItemCount (items over 35 MB or beyond the item limit). Add -IncludeSkippedItems to see which items were skipped. The stuck migration batch article covers slow batches.

Phased moves with split delivery

Split delivery lets one domain live on two systems. Mail enters through Microsoft 365 (the MX record points there), and a recipient that exists in Exchange Online is delivered there; any other recipient in that domain is relayed to cPanel. Microsoft's mail flow guidance recommends pointing MX at Microsoft 365 for the most accurate spam filtering when mailboxes are in two places.

The three steps, in the order to do them:

  1. Microsoft 365: set the accepted domain to Internal relay.
  2. Microsoft 365: create an outbound connector to the cPanel server, used only by a mail flow rule, and create the rule.
  3. cPanel: keep Email Routing on Local Mail Exchanger and replace moved users' mailboxes with forwarders.

Do all three and test before you change MX. The deeper concepts, other second hosts and a longer troubleshooting table are outside this migration guide's scope.

1. Internal relay

Microsoft defines Authoritative as delivering to listed recipients and rejecting unknown ones. Internal relay delivers to known recipients in Microsoft 365 and relays unknown ones to your own server, and requires a connector to that server. In the Exchange admin center go to Mail flow > Accepted domains, select example.com, and under This accepted domain is choose Internal relay, then Save. In PowerShell:

Set-AcceptedDomain -Identity example.com -DomainType InternalRelay

2. Connector and rule

In Mail flow > Connectors, select + Add a connector and set Connection from to Office 365 and Connection to to Your organization's email server (or Partner organization). Name it To cPanel, tick Turn it on, and on Use of connector choose Only when I have a transport rule set up that redirects messages to this connector. On Routing, enter mail.example.com and click + (Microsoft notes you must click it to continue). On Security restrictions, tick Always use Transport Layer Security (TLS) to secure the connection (recommended); the page then asks you to pick a criterion under Connect only if the recipient's email server certificate matches this criteria. Shared hosting often presents a certificate that does not match, which is the usual reason validation fails here. On Validation email, enter an address that exists only on cPanel, click +, then Validate, and finish with Create connector.

PowerShell equivalent:

New-OutboundConnector -Name "To cPanel" -ConnectorType Partner -UseMXRecord $false -SmartHosts mail.example.com -IsTransportRuleScoped $true -Enabled $true -TlsSettings EncryptionOnly

-TlsSettings EncryptionOnly encrypts the channel without certificate authentication; CertificateValidation and DomainValidation are stricter (with -TlsDomain) and are better if the cPanel server has a valid certificate for its name.

Then create the rule under Mail flow > Rules > Add a rule > Create a new rule. Name it Not in M365 to cPanel, set the condition to a recipient located Outside the organization plus recipient domain is example.com, set the action to Redirect the message to > the following connector > To cPanel, give it priority 0 and make sure it is enabled.

New-TransportRule -Name "Not in M365 to cPanel" -SentToScope NotInOrganization -RecipientDomainIs example.com -RouteMessageOutboundConnector "To cPanel" -Priority 0

Two cautions from the documentation. First, New-TransportRule creates rules enabled by default, but the portal lets you choose when to activate a rule, so confirm the rule shows as Enabled. Second, Microsoft's definition of NotInOrganization is a recipient whose address is not in an accepted domain, or is in a domain set as external relay, while InOrganization includes recipients in authoritative or internal relay domains. Read literally, that suggests a rule scoped this way would not match an internal relay domain. The setup this guide is based on reports that it works, but because the documentation reads differently, treat the test below as mandatory and do not change MX until a cPanel-only address receives mail through the rule.

3. The cPanel side

  • Email Routing. In cPanel Email > Email Routing, select the domain and choose Local Mail Exchanger. cPanel documents the options: Automatically Detect Configuration reads only the local zone file, Remote Mail Exchanger makes the server refuse mail for the domain and forward all of it to the lowest-numbered MX, and Local Mail Exchanger always accepts and delivers locally. With Remote or Automatic pointing at Microsoft 365 you get a loop: Microsoft sends unknown recipients to cPanel, and cPanel sends them straight back.
  • Moved users. When a user moves, delete their cPanel mailbox and add a forwarder from [email protected] to [email protected]. In cPanel use Forwarders > Add Forwarder, enter the part before the @ in Address to forward, pick the domain, and under the destination menu choose Forward to Email Address. Without this, mail from users still on cPanel to a moved colleague stays in the old local mailbox.
  • Port 25. The server must accept inbound SMTP on port 25 from Microsoft. Microsoft says to make sure your firewall accepts connections from the published Exchange Online address ranges. If the cPanel mail server rejects messages that fail SPF checks, relayed mail from Microsoft can be rejected; check the Exim settings in WHM.

Where to create what

AddressCreate it inDo not
A user staying on cPanelcPanel onlyCreate a Microsoft 365 user, contact, mail user, shared mailbox or group with that address
A user who has movedMicrosoft 365, then delete the cPanel mailbox and add the forwarderLeave the cPanel mailbox in place
A shared address (info@, sales@)The side that owns itCreate the same address in both

Test before MX

Send from a Microsoft 365 user to a cPanel-only user: it must arrive in cPanel webmail, and the message trace (see Message trace in Exchange Online) should show the route through the To cPanel connector. Then send from cPanel to a moved user and confirm it arrives in Microsoft 365 through the forwarder. The Exchange Online connectors guide and mail flow rules guide explain the objects used here.

Step 6: Switch MX, SPF and autodiscover

Do this once the batch has synced and, if phased, the test above passed.

  1. In the Microsoft 365 admin center, open Settings > Domains, select the domain, and view DNS records. Copy the MX value shown there; it looks like example-com.mail.protection.outlook.com. Do not type it from memory.
  2. At your DNS host, add that MX with the highest priority and remove or demote the old MX records.
  3. Keep an A record for mail.example.com pointing at 203.0.113.10. The connector and the IMAP endpoint both use that name.
  4. Add the autodiscover CNAME from the same page so Outlook configures itself.
  5. Publish one SPF record. Microsoft allows only one SPF record per domain and says duplicates cause permerror. While cPanel still sends mail for the domain, include its IP:
v=spf1 +a +mx ip4:203.0.113.10 include:spf.protection.outlook.com ~all

+a authorizes the domain's A record, +mx its MX hosts, ip4: the cPanel server, and the include authorizes Microsoft 365. Counting DNS lookups the way Microsoft documents them, a, mx and include: each count as one and ip4: and all do not, so this record uses at least 3 of the 10 allowed; the Microsoft include may add nested lookups. Once nothing else sends mail, tighten to v=spf1 include:spf.protection.outlook.com -all, Microsoft's recommended form.

After the MX change, send from an outside account such as Gmail to a moved user and to a cPanel-only user. Both must arrive, and the message trace should show each route. The SPF, DKIM and DMARC setup guide covers the policy side.

Step 7: DKIM, DMARC and clients

During coexistence both systems send mail as your domain, so both need to authenticate. For Microsoft 365, publish the two CNAME records Microsoft documents, with hostnames selector1._domainkey and selector2._domainkey, pointing to the values from your tenant:

Get-DkimSigningConfig -Identity example.com | Format-List Name,Enabled,Status,Selector1CNAME,Selector2CNAME
Set-DkimSigningConfig -Identity example.com -Enabled $true

If the cPanel server already signs mail, its key sits under its own selector name, so check the existing DNS TXT records before you add records. Start DMARC at a monitoring policy and review reports before you tighten it, as Microsoft advises for complex mail sources.

For clients, new Outlook profiles use autodiscover. Remove old IMAP accounts from phones and Outlook, add the Microsoft 365 account, and let it download mail. Users also need their contacts and calendars moved by hand, since the IMAP migration does not carry them.

Step 8: Finish and decommission

  1. Wait. Microsoft says it can take up to 72 hours for other systems to recognize the new MX, and advises letting the batch run at least 72 hours so at least one daily incremental sync catches late mail.
  2. Delete the batch. For IMAP, Microsoft's procedure is to delete the batch to stop synchronization (in the Exchange admin center, select the batch under Migration and choose Delete, or use Remove-MigrationBatch -Identity cPanelBatch1). IMAP batches are stopped by deleting them, not by a separate Complete step. After deletion, mail that still reaches cPanel is not copied.
  3. Remove the split delivery layer once every user is in Microsoft 365: delete the Not in M365 to cPanel rule and the To cPanel connector, then set the domain back:
Set-AcceptedDomain -Identity example.com -DomainType Authoritative
  1. Set cPanel Email Routing to Remote Mail Exchanger so mail generated on the server (website forms) goes to Microsoft 365 instead of dead local mailboxes.
  2. Keep a backup of the cPanel mailboxes for a retention period you choose, then close the mail accounts. Delete the CSV and reset or remove the temporary passwords.

Common mistakes

  • Mail loop. cPanel Email Routing set to Remote Mail Exchanger (or detected as such) during a phased move.
  • Rule left disabled. The connector exists but nothing sends mail to it; unknown recipients bounce.
  • Creating a cPanel-staying user in Microsoft 365. Their mail lands in Microsoft 365 and never reaches cPanel.
  • No forwarder for a moved user. cPanel users writing to them deliver into the old local mailbox.
  • Port 25 blocked. Connector validation and relay fail.
  • SPF rejects. A second SPF record, or a receiving server that rejects on SPF failure for relayed mail.

Troubleshooting

SymptomLikely causeFix
Connector validation failsPort 25 blocked or certificate mismatchOpen 25 for Microsoft ranges; revisit the TLS criteria option or use EncryptionOnly
Bounce for a cPanel-only address after MX changeDomain still Authoritative, or rule disabled or not matchingSet Internal relay, enable the rule, re-test
Mail ping-pongs and bounces with hop count errorsLoop from Remote or Automatic routing on cPanelSet Local Mail Exchanger
Moved user gets no mail from cPanel colleaguesOld cPanel mailbox still exists, no forwarderDelete the mailbox, add the forwarder
Migration user shows Failed with an authentication errorPassword in CSV wrong or changedFix the CSV or reset the password, retry the user
Test-MigrationServerAvailability failsWrong name, port or security, or firewallMatch the Set Up Mail Client values; allow Microsoft datacenter ranges
SPF permerrorTwo SPF records, or more than 10 lookupsMerge to one record, trim includes

Closing checklist

  • Inventory of mailboxes, forwarders, aliases and sizes done; MX TTL at 3,600 seconds or less.
  • Domain verified; only moving users created and licensed; MX untouched.
  • CSV built, test batch run, production batches started, CSV deleted afterwards.
  • For phased moves: Internal relay, connector, enabled rule, Local Mail Exchanger, forwarders, and a passing test.
  • MX, autodiscover, one SPF record and DKIM CNAMEs published from the admin center values.
  • Batch kept at least 72 hours, then deleted; rule and connector removed; domain Authoritative; cPanel routing Remote.

What we checked

  • Opened Microsoft Learn's Manage accepted domains in Exchange Online page on 2026-11-22; the Authoritative and Internal relay definitions, the Mail flow > Accepted domains path, and the Set-AcceptedDomain -Identity contoso.com -DomainType InternalRelay example match what this guide shows.
  • Opened the New-OutboundConnector and New-TransportRule reference pages on 2026-11-22 and confirmed -ConnectorType, -UseMXRecord, -SmartHosts, -IsTransportRuleScoped, -TlsSettings (EncryptionOnly, CertificateValidation, DomainValidation), -RouteMessageOutboundConnector, -SentToScope, -RecipientDomainIs and -Priority exist as used; New-TransportRule -Enabled defaults to $true.
  • Compared the -SentToScope value definitions on the transport rule page with the accepted-domain definitions and found the possible conflict about internal relay domains described above; this is why the guide makes the pre-MX test mandatory.
  • Read the cPanel Email Routing and Forwarders documentation on 2026-11-22 and matched the option names (Automatically Detect Configuration, Local, Backup, Remote Mail Exchanger) and the Add Forwarder fields.
  • Recalculated the SPF record's lookups from Microsoft's list of what counts: +a 1, +mx 1, include: 1, ip4: 0, ~all 0, total 3 before nested lookups inside Microsoft's include.
  • Checked the Exchange Online IP ranges page (last updated 10/30/2026): the page lists the SMTP ports 25 and ranges such as 40.92.0.0/15 for *.mail.protection.outlook.com; use the live page and not a copy.
  • Not checked: no tenant or cPanel server was available, so no cmdlet was run, no message trace was observed, and the report-line table is an interpretation of an administrator's experience, not Microsoft documentation. The exact wording of the second TLS option in the connector wizard and the Exim SPF setting name in WHM were not verified.

Last tested: 2026-11-22

References

Questions people ask

Can I migrate some cPanel mailboxes now and the rest later?

Yes. Set the domain in Exchange Online to Internal relay, add an outbound connector to the cPanel server and a mail flow rule that sends mail for unknown recipients there, and set cPanel Email Routing to Local Mail Exchanger. Mail then reaches whichever side holds the mailbox. Test it before you change the MX record.

Does the IMAP migration move contacts and calendars?

No. Microsoft documents that an IMAP migration only moves items in the inbox and other mail folders. Contacts, calendar items and tasks are not migrated, so export and import them separately.

How long should I keep the migration batch after changing MX?

Microsoft says it can take up to 72 hours for other systems to recognize a changed MX record and recommends letting the batch run at least 72 hours before you delete it. Deleting the batch stops synchronization.

Why does mail loop between cPanel and Microsoft 365?

The usual cause is cPanel Email Routing set to Remote Mail Exchanger (or Automatically Detect Configuration reading an MX that points at Microsoft 365) while Microsoft 365 forwards unknown recipients back to cPanel. Set the domain to Local Mail Exchanger on cPanel during a phased move.

Microsoft 365Exchange OnlinecPanelIMAP migrationSplit delivery