Error while Configuring SMTP and IMAP email accounts with Microsoft Office365 using OAuth2

Jayant Pandit
Giga Expert

We are following below document provided by SNOW,

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0816072

IMAP is working fine,

SMTP test connection showing below error.

"Connection Failed
Email sender connection invalid.: Cannot connect to SMTP server: smtp.office365.com"
 
Appreciate your inputs.
 
Thanks
Jayant
1 ACCEPTED SOLUTION

@Nguyen Minh Tam , @Kushal Bahirwani , @Jerry Wong 

Hello Everyone,

I managed to solve this on my own,

below are the steps.

 

Configure your OAuth Profile in Application Registry, Add Entity Scopes.

Create 2 Email Accounts, one for IMAP and another for SMTP.

When you click on "Authorize Email Account" .

Make sure that you are signed in as same email account in the browser that you want to configure for email sending and receiving.

 

For example.

My email ID is 'jayantcpandit@gmail.com'

Email that I want to configure is 'example@example.com'

In this case, I need to sign in to the browser with 'example@example.com' where I click on "Authorize Email Account", not with my 'jayantcpandit@gmail.com'

With this way, it will make sure that you are using correct account to authorize.

 

Hope this helps.

Please mark this helpful, if solves your issue.

 

Thanks

Jayant

View solution in original post

28 REPLIES 28

Hello Jerry!

Is this working for you now? I'm having the same error.

@Nguyen Minh Tam , @Kushal Bahirwani , @Jerry Wong 

Hello Everyone,

I managed to solve this on my own,

below are the steps.

 

Configure your OAuth Profile in Application Registry, Add Entity Scopes.

Create 2 Email Accounts, one for IMAP and another for SMTP.

When you click on "Authorize Email Account" .

Make sure that you are signed in as same email account in the browser that you want to configure for email sending and receiving.

 

For example.

My email ID is 'jayantcpandit@gmail.com'

Email that I want to configure is 'example@example.com'

In this case, I need to sign in to the browser with 'example@example.com' where I click on "Authorize Email Account", not with my 'jayantcpandit@gmail.com'

With this way, it will make sure that you are using correct account to authorize.

 

Hope this helps.

Please mark this helpful, if solves your issue.

 

Thanks

Jayant

Thanks @Jayant Pandit  for the comment.

But I'm not having any issue with "Authorize Email Account" . I can log in successfully with the correct account using incognito mode and received the correct access token & refresh token.

The step I'm having the issue with is when clicking on "Test Connection". I got the same error as you: 

"Connection Failed
Email sender connection invalid.: Cannot connect to SMTP server: smtp.office365.com"
 
I have assigned the mailbox license which can access Graph API but it didn't work.
Could you please let me know what did you do in this step?
Many thanks

Hello,

 

Please involve your IT team and re make sure below points

1) Configured Email Account have all required permission mentioned

 

2) API permission scopes assigned to registered Azure app are for Microsoft Graph resource. The mailbox might be assigned a license that doesn't have access to Graph API, e.g. Exchange Online (Plan 1). Switching to supported license, such as Office 365 E5 should fix the issue.

We need to make sure using E5.

 

3) Make sure email have SMTP enabled.

 

4) Make sure 'Server', 'Port' and 'Encryption' is configured correctly for both SMTP and IMAP email accounts in SNOW, follow below document

https://support.microsoft.com/en-us/office/pop-imap-and-smtp-settings-8361e398-8af4-4e97-b147-6c6c4ac95353?ui=en-us&rs=en-us&ad=us

 

Hope this helps,

I recommend connecting to ServiceNow Support and Involve Microsoft Support.

Would it be a problem if we have both Inbound and outbound email addresses are same ?

Like IMAP : 'example@example.com'

SMTP : 'example@example.com'  . Does this configuration work ?