Skip to content

idle function not returning any message when new mail comes #258

@syedajmal1998

Description

@syedajmal1998

idle function not returning any message when new mail comes

Config:

 'custom' => [ 'host' => 'outlook.office365.com', 'port' => 993, 'encryption' => "ssl", 'validate_cert' => true, 'username' => 'email@my_domain.com', 'password' => get_access_token(), 'authentication' => "oauth", ], // halper_functions.php function get_access_token() { $tenantId = env("TENANT_ID"); $clientId = env("CLIENT_ID"); $clientSecret = env("CLIENT_SECRET"); $guzzle = new \GuzzleHttp\Client(); $url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/v2.0/token'; $token = json_decode($guzzle->post($url, [ 'form_params' => [ 'client_id' => $clientId, 'client_secret' => $clientSecret, 'scope' => 'https://outlook.office.com/IMAP.AccessAsUser.All', 'grant_type' => 'password', 'username' => 'email@my_domain.com', 'password' => 'password', ], ])->getBody()->getContents()); $accessToken = $token->access_token; return $accessToken; }

custom command:

public function handle() { $client = Client::account("custom"); try { $client->connect(); } catch (ConnectionFailedException $e) { Log::error($e->getMessage()); return 1; } try { /** @var Folder $folder */ $folder = $client->getFolder("INBOX"); } catch (ConnectionFailedException $e) { Log::error($e->getMessage()); return 1; } catch (FolderFetchingException $e) { Log::error($e->getMessage()); return 1; } try { dump("listening..."); $folder->idle(function ($message) { dump($message); // this doesn't run }, 1200, true); } catch (ConnectionFailedException $e) { Log::error($e->getMessage()); return 1; }

but when i get messages manually it works

Route::get("test", function () { $client = Client::account("custom"); try { $client->connect(); } catch (ConnectionFailedException $e) { throw $e; } try { /** @var Folder $folder */ $folder = $client->getFolder("INBOX"); } catch (ConnectionFailedException $e) { throw $e; } catch (FolderFetchingException $e) { throw $e; } dump($client->getFolder("INBOX")->examine()); dump($client->getFolder("INBOX")->messages()->all()->limit(5)->get()); dd("done"); });

Screenshot 2022-08-19 034123
Screenshot 2022-08-19 034140

  • OS: CentOs (prod), win 11 (dev)
  • PHP: 8.1
  • webklex/laravel-imap : 2.4
  • Provider: Outlook

Metadata

Metadata

Assignees

No one assigned

    Labels

    OutlookRelated to OutlookbugSomething isn't workingvalidated

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions