Google dropped the support of user/password authentication as of 30 may 2022.
imap_open can not be used anymore, without the support of xoauth2.
https://support.google.com/accounts/answer/6010255
There is a ToDo from 2020 that didn't make it.
https://wiki.php.net/todo/ext/imap/xoauth2
The only way is to switch to a third party lib. "php-imap"
This is so sad.