Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No body parts when opening a Message from icloud #510

Open
lamigne opened this issue Aug 26, 2024 · 1 comment
Open

No body parts when opening a Message from icloud #510

lamigne opened this issue Aug 26, 2024 · 1 comment

Comments

@lamigne
Copy link

lamigne commented Aug 26, 2024

Describe the bug
When fetching a Message object from a icloud imap server, the message body part is empty, while the headers loads totally fine.
The Structure raw property is "" and parts is []

Used config
imap server : icloud
composer "webklex/php-imap": "dev-master#6d999438d29ed0bb920cd897b200a3a5fd6b6380" (to avoid composer requirements and other libraries check, #498 )

Code to Reproduce
The troubling code section which produces the reported bug.

 $cm = new ClientManager();
  $params = [
      'host'          => 'imap.mail.me.com',
      'port'          => 993,
      'encryption'    => 'ssl',
      'validate_cert' => true,
      'username'      => $username,
      'password'      => $password,
      'protocol'      => 'imap',
  ];
  
  $client = $cm->make($params);
  $client->connect();

  $folder = $client->getFolderByName('INBOX');

 if ($folder === null) {
            return false;
        }

        $messages = $folder
            ->messages()
            ->setFetchOrderAsc()
            ->all()
            ->since(new DateTimeImmutable('-10 years'))
            ->limit(10)
            ->get();

        for ($i = 0; $i < $messages->count(); ++$i) {
             $message = $messages[$i];
             print_r($message->getStructure());
        }

Expected behavior
$message->getStructure() should return a correct raw value with parsed parts array.

Desktop / Server (please complete the following information):

  • OS: mac OS 14.5
  • PHP: 8.3
  • Version: dev-master#6d999438d29ed0bb920cd897b200a3a5fd6b6380
  • Provider: icloud

Additional context
Only the body parts are empty, all the other features tested are working.
The package works fine when used with google (with OAuth2 of course)

As a temporary solution i use Ddeboer/imap for this icloud mailbox as it is not requiring OAuth token (yet)

@ybizeul
Copy link

ybizeul commented Aug 28, 2024

I'm troubleshooting an issue with iCloud and Freescout which is also using this module.

Some messages, not all, do not get the body fetched as part of the IMAP transaction, and it seems to be a known issue with iCloud. The workaround is to use BODY[TEXT] instead of RFC822.TEXT.

I don't see a variable in this module to alter the IMAP command used, so my fix was to change :

        return $this->fetch(["$rfc.TEXT"], is_array($uids) ? $uids : [$uids], null, $uid);

to

        return $this->fetch(["BODY[TEXT]"], is_array($uids) ? $uids : [$uids], null, $uid);

return $this->fetch(["$rfc.TEXT"], is_array($uids) ? $uids : [$uids], null, $uid);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@ybizeul @lamigne and others