Can't integrate Microsoft Office 365 to ERPNext

Hello everyone, I’m trying to integrate Office 365 to ERPNext but I’m getting this error in Email Account - "Incorrect Configuration: Invalid Outgoing Mail Server or Port and in Email Domain - "Incorrect email or password (ERPNext Notification) when trying to save them both. Our office365 is setup properly but still can’t authenticate in ERPNext. What could possibly be the problem? How can we fix this so we can integrate office365 to ERPNext? TIA

error
error2

ERPNext: v12.17.0
Frappe Framework: v12.14.0

The above method is depreciated. You may refer Oauth office 365

Thank you for your reply @shubham_agrawal. Is this applicable to my current version of ERPNext because I can’t see “Connected App” under Integration of ERPNext v12.