javanile / php-imap2

PHP IMAP with OAUTH2
https://php-imap2.javanile.org/
GNU General Public License v3.0
48 stars 28 forks source link

PHP IMAP2 : Outlook #42

Closed aicma closed 1 year ago

aicma commented 1 year ago

Hi im having issues with imap2_open() connecting to an Outlook Mailbox. this is my first time working with Azure and MS APIs so please forgive me any ignorance on Exchange/Outlook Admin topics.

I created the App in Azure and set permissions as stated in Step 1 & 2: http://wiki.canfigure.net/en/guides/exchange-oauth2 Ive done nothing in any Powershell as i dont seem to have access to the correct one (?)

Obtaining an Access_token works fine but when i call @imap2_open() the connections fails with Can not authenticate to IMAP server: A0001 NO AUTHENTICATE failed. Ive dug through a lot of stackoverflow, found some with somewhat similar issues but most solutions were to use a diffrent library in the end. Project is a "keep alive until replaced" so i cant throw in any complicated dependencies or want to rewrite most of the code.

aicma commented 1 year ago

Update: Ive now added the service Principals via the Exchange Powershell and added the Mailbox. Error ist still the same

aicma commented 1 year ago

Soluition was that i used the wrong Object-ID. this post helped me find the culprit https://www.limilabs.com/blog/oauth2-client-credential-flow-office365-exchange-imap-pop3-smtp