Those of you who have attempted to send mail to Office 365 from Azure know that sending outbound mail directly from an email server hosted in Azure is not supported due to elastic nature of public cloud service IPs and the potential for abuse. Therefore, the Azure IP address blocks are added to public block lists with no exceptions to this policy.
To be able to send mail from an Azure hosted email server to Office 365 you to need to send mail via a SMTP relay. There is a number of different SMTP relays you can utilise including Exchange Online Protection, more information can be found here: https://blogs.msdn.microsoft.com/mast/2016/04/04/sending-e-mail-from-azure-compute-resource-to-external-domains
To configure Exchange Server 2016 hosted in Azure to send mail to Office 365 via SMTP relay to Exchange Online protection you need to do the following;
- Create a connector in your Office 365 tenant
- Configure accepted domains on your Exchange Server in Azure
- Create a send connector on your Exchange Server in Azure that relays to Exchange Online Protection
Create a connector in your Office 365 tenant
- Login to Exchange Online Admin Center
- Click mail flow | connector
- Click +
- Select from: “Your organisation’s email server” to: “Office 365”
- Enter in a Name for the Connector | Click Next
- Select “By verifying that the IP address of the sending server matches one of these IP addresses that belong to your organization”
- Add the public IP address of your Exchange Server in Azure
Configure accepted domains on your Exchange Server in Azure
- Open Exchange Management Shell
- Execute the following PowerShell command for each domain you want to send mail to in Office 365;
New-AcceptedDomain -DomainName Contoso.com -DomainType InternalRelay -Name Contoso
Create a send connector on your Exchange Server in Azure that relays to Exchange Online Protection
- Execute the following PowerShell command;
New-SendConnector -Name “My company to Office 365” -AddressSpaces * -CloudServicesMailEnabled $true -RequireTLS $true -SmartHosts yourdomain-com.mail.protection.outlook.com -TlsAuthLevel CertificateValidation