To eliminate these issues for users with cloud mailboxes, perform the following steps:
Create a CNAME record in DNS that points to mail.office365.com:
Be sure to create this CNAME record in your internal and external (public) DNS, because users might connect from internal or external Internet connections.
In our example, the domain contoso.com is used in the request. This means you don't need to specify the domain in the URL.
Configure the Outlook on the web redirect in the on-premises organization relationship: To do this, use the following syntax in the Exchange Management Shell in on-premises Exchange:
Set-OrganizationRelationship -Identity <Organization relationship identity> -TargetOWAUrl http://<CNAME value>/owa
I hope this helps!