barbushin / php-imap

Manage mailboxes, filter/get/delete emails in PHP (supports IMAP/POP3/NNTP)
MIT License
1.65k stars 459 forks source link

How to connect O365 ? #681

Open gamersalpha opened 1 year ago

gamersalpha commented 1 year ago

Hello evrybody,

how to connet mailbox to Office 365 From Microsoft

i got evry time this error :

user@web2:/var/www/html/$ php demo_O365.php 
...Start connection O365 ...PHP Fatal error:  Uncaught Exception: IMAP error: Can not authenticate to IMAP server: AUTHENTICATE failed. in /var/www/html/vendor/php-imap/php-imap/src/PhpImap/Mailbox.php:413
Stack trace:
#0 /var/www/html/vendor/php-imap/php-imap/src/PhpImap/Mailbox.php(385): PhpImap\Mailbox->initImapStream()
#1 /var/www/html/vendor/php-imap/php-imap/src/PhpImap/Mailbox.php(324): PhpImap\Mailbox->initImapStreamWithRetry()
#2 /var/www/html/vendor/php-imap/php-imap/src/PhpImap/Mailbox.php(1441): PhpImap\Mailbox->getImapStream()
#3 /var/www/html/demo_phpimap_O365.php(38): PhpImap\Mailbox->imap('check')
#4 {main}
  thrown in /var/www/html/vendor/php-imap/php-imap/src/PhpImap/Mailbox.php on line 413

Fatal error: Uncaught Exception: IMAP error: Can not authenticate to IMAP server: AUTHENTICATE failed. in /var/www/html/vendor/php-imap/php-imap/src/PhpImap/Mailbox.php:413
Stack trace:
#0 /var/www/html/vendor/php-imap/php-imap/src/PhpImap/Mailbox.php(385): PhpImap\Mailbox->initImapStream()
#1 /var/www/html/vendor/php-imap/php-imap/src/PhpImap/Mailbox.php(324): PhpImap\Mailbox->initImapStreamWithRetry()
#2 /var/www/html/vendor/php-imap/php-imap/src/PhpImap/Mailbox.php(1441): PhpImap\Mailbox->getImapStream()
#3 /var/www/html/demo_phpimap_O365.php(38): PhpImap\Mailbox->imap('check')
#4 {main}
  thrown in /var/www/html/vendor/php-imap/php-imap/src/PhpImap/Mailbox.php on line 413
PHP Notice:  Unknown: Can not authenticate to IMAP server: AUTHENTICATE failed. (errflg=2) in Unknown on line 0

Notice: Unknown: Can not authenticate to IMAP server: AUTHENTICATE failed. (errflg=2) in Unknown on line 0

the user and password are good

derrickbathory commented 1 year ago

Microsoft disabled your plain authentication.

https://techcommunity.microsoft.com/t5/exchange-team-blog/basic-authentication-and-exchange-online-september-2021-update/ba-p/2772210

gamersalpha commented 1 year ago

Hello, thanks,

Microsoft change the game !

All program have to update theyr connector wiht Microsoft connector :/

can phpipam, will get this function ?

thanks

vielhuber commented 1 year ago

This is huge.

Does anybody have a solution that php-imap works again (e.g. with the help of https://github.com/javanile/php-imap2)?

gamersalpha commented 1 year ago

u can contact the support Microsoft on u tenant acess, thay will help u to activate the IMAP on u account with powershel command that's works now for me

just hope Microsoft will not disable this acess forever

thanks

juangacovas commented 1 year ago

O365: "Please understand we will be disabling basic auth for all tenants permanently in January 2023, regardless of their opt-out status." as seen here.

nettunodev commented 1 year ago

This is huge.

Does anybody have a solution that php-imap works again (e.g. with the help of https://github.com/javanile/php-imap2)?

I renamed all the php_imap functions in this library to php2_imap functions and added the Javanile/php-imap2 library and it does work. Still, that library is very young and it does have some issues, but maybe it fits your needs.

diegofn commented 1 year ago

Hello,

Is there any plan or kickstart to support O365 new imap rules on this library?

kurznet commented 1 year ago

Is there any plan or kickstart to support O365 new imap rules on this library?

I would be interested in that too?

diegofn commented 1 year ago

Is there any plan or kickstart to support O365 new imap rules on this library?

I would be interested in that too?

Yes, we need that O365 support can be release as soon as posible.