Connection to smtp.office365.com fails with the error 535 5.7.3 Authentication unsuccessful


Description

You may encounter an issue when setting up a new email account with the following properties:

Connection may fail with the error:
WARNING *** WARNING *** Cannot connect to SMTP server: smtp.office365.com, as: abc@xyz.com, message: 535 5.7.3 Authentication unsuccessful

Cause

This can happen for many reasons but the most common cause is that the ServiceNow source IP addresses are blocked on the Office365 side which maybe configured with a conditional access rule. To find the exact cause, check the Azure logs for failed authentication and the reason for the failure should be documented there. 

Resolution

Obtain the source IP ranges from the IP Information page from your instance.

The IP ranges required to be inclusion listed are listed in the second row named Source address used for integrations into customer network with NO VPN.

Note: The fix can take a few minutes to propagate in Office365. Allow a couple of minutes before testing the connection again from ServiceNow.