SMTP with Oauth2 via office365

Tommy Jensen
Giga Guru

For a customer I am trying to setup outgoing emails via office365 using SMTP + OAuth2 authentication.

The oauth authentication works.
ServiceNow can connect to the serrver and deliver mails to office365.

However the emails are not sent because office365 replies with following error on the emails.

"451 4.4.62 Mail sent to the wrong Office 365 region. ATTR35. For more information please go to https://go.microsoft.com/fwlink/?linkid=865268 [ValidationStatus of '' is EmptyCertificate]"

I do not know what that means, the link does not give me any clues except that something somewhere might be misconfigured.

The customer is very small so they do not have an IT department so I am working with a third party who handles all IT related and they setup the Oauth authentication etc. They do not know what to do and they expect that ServiceNow provides exact instructions on to to set this up. I have referred them to the relevant documentation from ServiceNow.


Has anybody had the same problem and how did you solve it? I do NOT want to use basic auth since that will be disabled in september. So I will not setup a solution I know will stop working in a few months.



6 REPLIES 6

VikMach
Mega Sage

Hi @Tommy,
Complete setup guide is provided under ServiceNow Docs -
https://www.servicenow.com/docs/bundle/yokohama-platform-administration/page/administer/notification...

 

It is under Advanced Email Setup  section -
https://www.servicenow.com/docs/bundle/yokohama-platform-administration/page/administer/reference-pa...

 

Microsoft has announced and documented support for OAuth here:

  1. Microsoft's announcement of support for OAuth 2.0 with their IMAP and SMTP services
  2. Microsofts official documentation for configuring SMTP/IMAP with OAuth 2.0


Let me know if this works.

Regards,
Vikas K

All that have been done. As I already mentioned both authentication and connection IS working. 

Ok.
I have gone through the error "...Mail sent to the wrong Office 365 region...." and read the given suggested article it is pointing at mail server used for relay for external application. It uses one MX record as a connector which is standard record created in Microsoft O365 Admin Center to read the incoming email and route it to the right mailbox. It looks like from the error it is not able to identify and route the incoming email. Suggested solution is to use the GUID as a prefix in that record in order for the incoming emails to identify and route to correct mailbox. You need to work with your O365 Admin to correct some setup in both ServiceNow and O365. I am seeing this has something to do with email server used in the ServiceNow.

Vikas1_1-1746098790895.png


As you mentioned both authentication and connection IS working but email routing mechanism in O365 Admin center looks for Accepted Domain while routing, which I believe is a mismatch and that is the whole reason it throws an error stating "...Mail sent to the wrong Office 365 region...".

Also, there is a suggestion to fix smart hosting. You might want to check with the O365 Admin on that.

Those are my findings. By the way what is the Server value you have entered in the ServiceNow? Just curious!

Hope that will help.

Regards,
Vikas K 

Tommy Jensen
Giga Guru

I am still facing this issue.

But now the IT vendor claims that it is not possible to do with a solution from MS.  And they say we need to use alternative solutions to send emails.