after one day of trying, I have a solution now, that I want to document here:
I use Office 365 as an Email provider in my company. In this tutorial I explain how to set it up. I assume, that you are the owner & admin of the office 365 company account.
goto: admin.microsoft.com -> Exchange
goto ‘Mail Flow’ -> Connectors
Add a Connector
From: E-Mail Server of your company
To: Office 365
Add the IP of your ERP-next Server
While setting up you Domain, you will create a MX-record that looks something like:
Preparing the Email Account
Your Email Account can not be a admin in your organisation! If that is the case you have to deactivate the azure security defaults: https://docs.microsoft.com/de-de/azure/active-directory/fundamentals/concept-fundamentals-security-defaults#policies-enforced
Create a non-admin Email account.
Goto https://aad.portal.azure.com/ >> Users >> Multi-Factor-Authentication
Click on your user and deactivate MFA in the quicksteps.
ERPnext >> Settings >> Email Domain
Email Server: outlook.office365.com
Use IMAP: true
Use SSL: true
SMTP Server: YOURCOMAPNYNAME01i.mail.protection.outlook.com
Use TLS: true
Use SSL: false
ERPnext >> Settings >> Email Account
Email Address: firstname.lastname@example.org
Disable SMTP server authentication: true
Let me know if that worked for you. I spend one day figuring out what to set up - hopfully this post helps you to do it quicker.
I am well aware, that you can use MFA and create an APP-Password. Feel free to contribute a tutorial if you need that.
You can set up App passwords here, after you have activated MFA.