This article will explain how to create mail flow coexistence between disparate IMAP source and Exchange Online destination.
Use case:
- Customer wants a mailflow co-existence between hosted email e.g. Gmail and Exchange Online during mailbox migration phase.
- Customer has on-premises Exchange Server but does not want to create hybrid environment or have a situation where hybrid configuration is not feasible.
- Customer plans to migrate mailboxes, calendar, contacts, resources and distribution groups to Exchange Online in phases.
- Customer does not want a cutover migration to Exchange Online.
Source Environment:
- Email Domain: Domain.com
- Migration Method: IMAP
- Source Infrastructure: On-premises Microsoft Exchange or Hosted Gmail
Destination Environment:
- Office 365 Tenant: domain.onmicrosoft.com
- Default Domain: domain.onmicrosoft.com
- Email Domain: Domain.com
- CatchAll Domain or Subdomain: subdomain.domain.com
Migration Method:
- Pre-stage: In pre-stage migration, data will be pre-filled to a place holder mailbox then migrate delta changes.
- Backfill: In backfill method, data will be back filled to a real mailbox after cutover.
Prepare Source Email Domain:
- Add Proxy address or alias to all mailboxes.
To add proxy address, create a CSV file with the below header and run the scripts
Name, EmailAddress
User1@domain.com, user1@domain.onmicrosoft.com
Import-Csv c:\data.csv | Foreach{
$maileg = Get-Mailbox -Identity $_.Name
$maileg.EmailAddresses += $_.emailaddress
$maileg | Set-Mailbox -EmailAddresses $_.emailaddress
}
- Create target address or forwarding address to all mailboxes. To add target address, create a CSV file with the below header and run the script
CSV Headers are Mailbox, ForwardTo
User1@domain.com, user1@domain.onmicrosoft.com
user1@domain.com, user1@subdomain.domain.com
Import-CSV “C:\CSV\Users.csv” | ForEach {Set-Mailbox -Identity $_.mailbox -ForwardingAddress $_.forwardto}
- Send & Receive Connector
If you have strict mailflow condition on the on-premises environment or hosted environment, you may have to create a send connector and receive connector to allow Office 365 email in both directions.
- MX record still pointed to source environment.
Prepare Exchange Online
- Create Office 365 tenant: domain.onmicrosoft.com
- Add customer domain e.g. domain.com on the Office 365 portal and validate the domain
- Go to Office 365 ECP, Select Mailflow, Click Accepted Domain, Select Domain.com, Click Edit and set the domain to Internal Relay
- Go to Office 365 ECP, Select Recipient, Go to Groups, Create a distribution group and add all users to the distribution group. To find a script to do the job, refer to step3 of post migration section of this article. replace remove-distributiongroupmember to add-distributiongroupmember on the script.
- Go to Office 365 ECP, Select Mailflow, Connectors, create an Outbound Send Connector to send email from Office 365 to Your organisation email server. When creating this Connector select the smart host option and on the smart host window, type the Public IP Address or FQDN of MX record of domain.com
- Go to Office 365 ECP, Select Mailflow, Rules, create a rule to forward any inbound emails coming to @domain.com and member of special distribution group created in step 4 to be forwarded to the send connector you have created in previous steps 5.
- Enable Mailflow for subdomain or catchall domain i.e. @subdomain.domain.com Set-AcceptedDomain -Identity domain.com -MatchSubdomains $true
Mailflow during migration phase
When an Exchange Online mailbox user1@domain send mail to user2@domain.com (On-premises/hosted Gmail), as user2 does not exist at Exchange Online side, and the domain: domain.com set as “Internal Relay” under “Accept domain” configuration, so the message will delivery to on-premises/Gmail through special outbound connector.
Post Migration:
Once you have migrated a batch of mailboxes, you have to remove proxy address and forwarding address from that batch of source mailboxes on the source email domain.
- Remove Proxy Address from Source Environment
CSV Headers are Name and EmailAddress
User1@domain.com, user1@domain.onmicrosoft.com
Import-Csv C:\CSV\ProxyAddress.csv | Foreach{
$maileg = Get-RemoteMailbox -Identity $_.Name
$maileg.EmailAddresses += $_.emailaddress
$maileg | Set-Mailbox -EmailAddresses @{Remove=$_.EmailAddress} }
- Remove Forwarding address from Source Environment
CSV headers are Mailbox, ForwardTo
User1@domain.com, user1@domain.onmicrosoft.com
Import-CSV “C:\CSV\Users.csv” | ForEach {Set-Mailbox -Identity $_.mailbox -ForwardingAddress @{Remove=$_.forwardto}}
- Remove the batch of mailboxes from the distribution groups once migrated to Office 365.
CSV Headers are
Identity, Members
Accounts, user1@domain.com
Import-Csv “C:\CSV\RemoveMembers.csv” | foreach{Remove-DistributionGroupMember -Identity $_.identity -Member $_.members}
- Delete special Distribution Group, Maiflow rule and Outbound Connector created on the step 4, step 5 and step 6 after MX record cutover to Office 365.