Failed IMAP Connection with Webklex PHP-IMAP and OAuth Token

24 Views Asked by At

I'm trying to establish an IMAP connection using Webklex PHP-IMAP library with Office365. I've successfully generated an access token using client ID, secret, tenant ID, username, and password. However, when I try to connect using the token as the password with SSL encryption and OAuth authentication, the connection fails. Other methods work, but not with PHP-IMAP. Any insights or solutions?

    $cm = new ClientManager();
$client = $cm->make([
    'host' => 'outlook.office365.com',
    'port' => 993,
    'encryption' => 'ssl',
    'validate_cert' => true,
    'protocol' => 'imap',
    'username' => $username,
    'password' => $access_token,
    'authentication' => "oauth",
]);
$client->connect();
0

There are 0 best solutions below