Check Mail-Delivery-Process via "modern auth" (Microsoft Outlook)

Well, for us it’s pretty simple - I don’t particularly care about the protocols, I just want to be able to confirm that I can send and receive an email to/from O365 (given that most customers are hosted there). If check_mail_loop can do this purely through EWS, then everything is fine.

Currently a command of ours looks like this:

check_mk_active-mail_loop!'--smtp-server=$HOSTADDRESS$' '--smtp-tls' '--fetch-protocol=IMAP' '--fetch-server=outlook.office365.com' '--fetch-tls' '--fetch-username=mailtest2@customer.domain' '--fetch-password=testmail2' '--mail-from=mailtest1@customer.domain' '--mail-to=customer-loop@gmx.de' '--delete-messages' '--status-suffix=customer-domain.mail.protection.outlook.com-Exchange-GMX-Exchange' '--warning=300' '--critical=600'

And this (obviously) fails with “Failed to connect to outlook.office365.com:993: error(b’LOGIN failed.')”

If we can implement a way to talk to O365 in order to send an email or to verify its existence in a mailbox (and delete it!) then that’s all we need.