To support the so called shared mailboxes with OAUTH2 I would suggest following changes:
Within the Connection class add a new protected property $sharedUser.
Within the Connection classes openMailbox method add the following snippet: $this->sharedUser = array_reduce($mailboxParts['path'], function($carry, $item) { return preg_match('/^user=(.+)$/', $item, $matches) ? $matches[1] : $carry; }, false);
Within the Connection classes connect method change the 2nd argument of the connect call to: ($this->flags & OP_XOAUTH2) && !empty($this->sharedUser) ? $this->sharedUser : $this->user
Maybe the ($this->flags & OP_XOAUTH2) part in step 3 might be omitted - haven't tried php-imap2 with normal IMAP login in combination with shared mailboxes - in which case I would use PHP's integrated imap_ functions anyway :p
To support the so called shared mailboxes with OAUTH2 I would suggest following changes:
$sharedUser
.$this->sharedUser = array_reduce($mailboxParts['path'], function($carry, $item) { return preg_match('/^user=(.+)$/', $item, $matches) ? $matches[1] : $carry; }, false);
($this->flags & OP_XOAUTH2) && !empty($this->sharedUser) ? $this->sharedUser : $this->user
Maybe the($this->flags & OP_XOAUTH2)
part in step 3 might be omitted - haven't tried php-imap2 with normal IMAP login in combination with shared mailboxes - in which case I would use PHP's integrated imap_ functions anyway :p